pudo / dataset

Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.

Home Page:https://dataset.readthedocs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

table.find startswith/endswith are reversed

mijaba opened this issue · comments

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.

Thanks for the fix in #381.