Merge "Don't allow queries with 'IN' predicate with an empty sequence"

This commit is contained in:
Jenkins 2014-04-26 10:42:42 +00:00 committed by Gerrit Code Review
commit b6de8ddc0d
3 changed files with 8 additions and 6 deletions

View File

@ -1167,7 +1167,8 @@ class ValidatedComplexQuery(object):
schema_value_in = {
"type": "array",
"items": {"oneOf": [{"type": "string"},
{"type": "number"}]}}
{"type": "number"}]},
"minItems": 1}
schema_field = {
"type": "object",

View File

@ -392,3 +392,9 @@ class TestFilterSyntaxValidation(test.BaseTestCase):
self.assertRaises(jsonschema.ValidationError,
self.query._validate_filter,
filter)
def test_empty_in_query_not_passing(self):
filter = {"in": {"resource_id": []}}
self.assertRaises(jsonschema.ValidationError,
self.query._validate_filter,
filter)

View File

@ -943,11 +943,6 @@ class ComplexSampleQueryTest(DBTestBase,
self.assertTrue(sample.counter_volume > 0.4)
self.assertTrue(sample.counter_volume <= 0.8)
def test_query_filter_with_empty_in(self):
results = list(
self.conn.query_samples(filter_expr={"in": {"resource_id": []}}))
self.assertEqual(len(results), 0)
def test_query_simple_metadata_filter(self):
self._create_samples()