Merge "Change API filter wildcard from '%' to '*'"
This commit is contained in:
commit
55a158ae1b
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user