From 2acd806db34bbca3a488123cf67515e59e7bea98 Mon Sep 17 00:00:00 2001 From: Jordan Cazamias Date: Tue, 1 Jul 2014 13:03:34 -0500 Subject: [PATCH] Change API filter wildcard from '%' to '*' Change-Id: I9d48b5c40744a9b3179040d79ee9a1784d83b7bd Fixes: bug 1335902 --- designate/storage/impl_sqlalchemy/__init__.py | 6 ++++-- designate/tests/test_storage/__init__.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/designate/storage/impl_sqlalchemy/__init__.py b/designate/storage/impl_sqlalchemy/__init__.py index f51b284f..d139fc85 100644 --- a/designate/storage/impl_sqlalchemy/__init__.py +++ b/designate/storage/impl_sqlalchemy/__init__.py @@ -72,8 +72,10 @@ class SQLAlchemyStorage(base.Storage): for name, value in criterion.items(): column = getattr(model, name) - if isinstance(value, basestring) and '%' in value: - query = query.filter(column.like(value)) + # Wildcard value: '*' + if isinstance(value, basestring) and '*' in value: + queryval = value.replace('*', '%') + query = query.filter(column.like(queryval)) else: query = query.filter(column == value) diff --git a/designate/tests/test_storage/__init__.py b/designate/tests/test_storage/__init__.py index 6b4d3253..a7c087ad 100644 --- a/designate/tests/test_storage/__init__.py +++ b/designate/tests/test_storage/__init__.py @@ -878,7 +878,7 @@ class StorageTestCase(object): criterion = dict( domain_id=domain['id'], - name="%%%s" % domain['name'], + name="*%s" % domain['name'], ) results = self.storage.find_recordsets(self.admin_context, criterion) @@ -1092,7 +1092,7 @@ class StorageTestCase(object): criterion = dict( domain_id=domain['id'], recordset_id=recordset['id'], - data="%%.0.0.1", + data="*.0.0.1", ) results = self.storage.find_records(self.admin_context, criterion)