def _to_filter(self, bindings): assert self.__opsymbol not in ('!=', 'in'), self.__opsymbol value = self.__value if isinstance(value, Binding): bindings[value.key] = value value = value.resolve() return datastore_query.make_filter(self.__name, self.__opsymbol, value)
def GetFilterPredicate(self, *args, **kwds): """Adds filters for the search query, then delegates to the superclass. Mimics Query.GetFilterPredicate()'s signature. Raises BadFilterError if a filter on the index property already exists. Returns: datastore_query.FilterPredicate """ properties = getattr(self, "_properties", ALL_PROPERTIES) index_property_name = SearchableEntity.IndexPropertyName(properties) if index_property_name in self: raise datastore_errors.BadFilterError( '%s is a reserved name.' % index_property_name) filter = super(SearchableQuery, self).GetFilterPredicate(*args, **kwds) if hasattr(self, '_search_query'): keywords = SearchableEntity._FullTextIndex( self._search_query, self._word_delimiter_regex) if keywords: search_filter = datastore_query.make_filter( index_property_name, '=', list(keywords)) if filter: filter = datastore_query.CompositeFilter( datastore_query.CompositeFilter.AND, [filter, search_filter]) else: filter = search_filter return filter
def GetFilterPredicate(self, *args, **kwds): """Adds filters for the search query, then delegates to the superclass. Mimics Query.GetFilterPredicate()'s signature. Raises BadFilterError if a filter on the index property already exists. Returns: datastore_query.FilterPredicate """ properties = getattr(self, "_properties", ALL_PROPERTIES) index_property_name = SearchableEntity.IndexPropertyName(properties) if index_property_name in self: raise datastore_errors.BadFilterError('%s is a reserved name.' % index_property_name) filter = super(SearchableQuery, self).GetFilterPredicate(*args, **kwds) if hasattr(self, '_search_query'): keywords = SearchableEntity._FullTextIndex( self._search_query, self._word_delimiter_regex) if keywords: search_filter = datastore_query.make_filter( index_property_name, '=', list(keywords)) if filter: filter = datastore_query.CompositeFilter( datastore_query.CompositeFilter.AND, [filter, search_filter]) else: filter = search_filter return filter
def _to_filter(self, bindings, post=False): if post: return None assert self.__opsymbol not in ('!=', 'in'), repr(self.__opsymbol) value = self.__value if isinstance(value, Binding): bindings[value.key] = value value = value.resolve() return datastore_query.make_filter(self.__name, self.__opsymbol, value)