@@ -86,6 +86,9 @@ class Query(object):
86
86
"<" : query_pb2 .PropertyFilter .Operator .LESS_THAN ,
87
87
">" : query_pb2 .PropertyFilter .Operator .GREATER_THAN ,
88
88
"=" : query_pb2 .PropertyFilter .Operator .EQUAL ,
89
+ "!=" : query_pb2 .PropertyFilter .Operator .NOT_EQUAL ,
90
+ "IN" : query_pb2 .PropertyFilter .Operator .IN ,
91
+ "NOT_IN" : query_pb2 .PropertyFilter .Operator .NOT_IN ,
89
92
}
90
93
"""Mapping of operator strings and their protobuf equivalents."""
91
94
@@ -215,7 +218,7 @@ def add_filter(self, property_name, operator, value):
215
218
216
219
where property is a property stored on the entity in the datastore
217
220
and operator is one of ``OPERATORS``
218
- (ie, ``=``, ``<``, ``<=``, ``>``, ``>=``):
221
+ (ie, ``=``, ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``IN``, ``NOT_IN`` ):
219
222
220
223
.. testsetup:: query-filter
221
224
@@ -235,7 +238,7 @@ def add_filter(self, property_name, operator, value):
235
238
:param property_name: A property name.
236
239
237
240
:type operator: str
238
- :param operator: One of ``=``, ``<``, ``<=``, ``>``, ``>=``.
241
+ :param operator: One of ``=``, ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``IN``, ``NOT_IN`` .
239
242
240
243
:type value: :class:`int`, :class:`str`, :class:`bool`,
241
244
:class:`float`, :class:`NoneType`,
@@ -252,7 +255,7 @@ def add_filter(self, property_name, operator, value):
252
255
"""
253
256
if self .OPERATORS .get (operator ) is None :
254
257
error_message = 'Invalid expression: "%s"' % (operator ,)
255
- choices_message = "Please use one of: =, <, <=, >, >=."
258
+ choices_message = "Please use one of: =, <, <=, >, >=, !=, IN, NOT_IN ."
256
259
raise ValueError (error_message , choices_message )
257
260
258
261
if property_name == "__key__" and not isinstance (value , Key ):
@@ -293,7 +296,7 @@ def key_filter(self, key, operator="="):
293
296
:param key: The key to filter on.
294
297
295
298
:type operator: str
296
- :param operator: (Optional) One of ``=``, ``<``, ``<=``, ``>``, ``>=``.
299
+ :param operator: (Optional) One of ``=``, ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``IN``, ``NOT_IN`` .
297
300
Defaults to ``=``.
298
301
"""
299
302
self .add_filter ("__key__" , operator , key )
0 commit comments