Merge "Change API filter wildcard from '%' to '*'"

This commit is contained in:
Jenkins 2014-07-03 15:40:20 +00:00 committed by Gerrit Code Review
commit 55a158ae1b
2 changed files with 6 additions and 4 deletions

View File

@ -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)

View File

@ -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)