table.find startswith/endswith are reversed
mijaba opened this issue · comments
mijaba commented
When using table.find for strings, the startswith
and endswith
operators for advanced filters appear to be reversed. This can be seen using:
import dataset
db = dataset.connect('sqlite:///withbug.db')
table = db['names']
table.insert(dict(name='John Doe'))
table.insert(dict(name='Jane Doe'))
print('Names starting with Doe - should be empty')
print(list(table.find(name={'startswith': 'Doe'})))
print('Names ending with Doe - should be both')
print(list(table.find(name={'endswith': 'Doe'})))
The above produces:
Names starting with Doe - should be empty
[OrderedDict([('id', 1), ('name', 'John Doe')]), OrderedDict([('id', 2), ('name', 'Jane Doe')])]
Names ending with Doe - should be both
[]
It appears that the problem is in lines 416 and 418 of table.py
.
Friedrich Lindenberg commented
Thanks for the fix in #381.