Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Makes operator checking deterministic in Query.filter.#294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f8a4db4799b6b7f47ffa11fb43bdFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -63,21 +63,57 @@ def test_to_protobuf_w_kind(self): | ||
| kq_pb, = list(q_pb.kind) | ||
| self.assertEqual(kq_pb.name, _KIND) | ||
| def test_filter_w_no_operator(self): | ||
| query = self._makeOne() | ||
| self.assertRaises(ValueError, query.filter, 'firstname', 'John') | ||
| def test_filter_w_unknown_operator(self): | ||
| query = self._makeOne() | ||
| self.assertRaises(ValueError, query.filter, 'firstname ~~', 'John') | ||
| def test_filter_w_known_operator(self): | ||
| from gcloud.datastore import datastore_v1_pb2 as datastore_pb | ||
| query = self._makeOne() | ||
| after = query.filter('firstname =', u'John') | ||
| self.assertFalse(after is query) | ||
| self.assertTrue(isinstance(after, self._getTargetClass())) | ||
| q_pb = after.to_protobuf() | ||
| self.assertEqual(q_pb.filter.composite_filter.operator, 1) # AND | ||
| self.assertEqual(q_pb.filter.composite_filter.operator, | ||
| datastore_pb.CompositeFilter.AND) | ||
| f_pb, = list(q_pb.filter.composite_filter.filter) | ||
| p_pb = f_pb.property_filter | ||
| self.assertEqual(p_pb.property.name, 'firstname') | ||
| self.assertEqual(p_pb.value.string_value, u'John') | ||
| self.assertEqual(p_pb.operator, datastore_pb.PropertyFilter.EQUAL) | ||
| def test_filter_w_all_operators(self): | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| from gcloud.datastore import datastore_v1_pb2 as datastore_pb | ||
| query = self._makeOne() | ||
| query = query.filter('leq_prop <=', u'val1') | ||
| query = query.filter('geq_prop >=', u'val2') | ||
| query = query.filter('lt_prop <', u'val3') | ||
| query = query.filter('gt_prop >', u'val4') | ||
| query = query.filter('eq_prop =', u'val5') | ||
| query_pb = query.to_protobuf() | ||
| pb_values = [ | ||
| ('leq_prop', 'val1', | ||
| datastore_pb.PropertyFilter.LESS_THAN_OR_EQUAL), | ||
| ('geq_prop', 'val2', | ||
| datastore_pb.PropertyFilter.GREATER_THAN_OR_EQUAL), | ||
| ('lt_prop', 'val3', datastore_pb.PropertyFilter.LESS_THAN), | ||
| ('gt_prop', 'val4', datastore_pb.PropertyFilter.GREATER_THAN), | ||
| ('eq_prop', 'val5', datastore_pb.PropertyFilter.EQUAL), | ||
| ] | ||
| query_filter = query_pb.filter.composite_filter.filter | ||
| for filter_pb, pb_value in zip(query_filter, pb_values): | ||
| name, val, filter_enum = pb_value | ||
| prop_filter = filter_pb.property_filter | ||
| self.assertEqual(prop_filter.property.name, name) | ||
| self.assertEqual(prop_filter.value.string_value, val) | ||
| self.assertEqual(prop_filter.operator, filter_enum) | ||
| def test_filter_w_known_operator_and_entity(self): | ||
| import operator | ||
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.