Bug in __gte for string filters
IanMayo opened this issue · comments
Describe the bug
When providing a string filter to __gte
the query fails if the string contains a -
character
To Reproduce
Steps to reproduce the behavior:
- Run
soul-cli
, connecting tochinook.db
- Enter this URL:
http://localhost:8000/api/tables/invoices/rows?_filters=BillingAddress__gte:Theodor
- Note that there are 21 matching records, and the first has a BillingAddress of
Theodor-Heuss-Straße 34
- Now filter for address including the hyphen:
Theodor-Heuss
. So a URL of:http://localhost:8000/api/tables/invoices/rows?_filters=BillingAddress__gte:Theodor-Heuss
- Note that
Soul
returns an error:
{"message":"near "LIMIT": syntax error","error":{"code":"SQLITE_ERROR"}}
Note:
We seem to have a related issue with filters on InvoiceDate that contain a "-".
http://localhost:8000/api/tables/invoices/rows?_filters=InvoiceDate:2009-01-01%2000:00:00
Returns this:
{"message":"near ".01": syntax error","error":{"code":"SQLITE_ERROR"}}
Note 2:
The invoices are all dated 2009. So this query reports 412 matching records:
http://localhost:8000/api/tables/invoices/rows?_page=1&_limit=20&_filters=InvoiceDate__gt:2009
But, if I change the year to 2030, there are still 412 matching records:
http://localhost:8000/api/tables/invoices/rows?_page=1&_limit=20&_filters=InvoiceDate__gt:2030
In contrast, using a __lt
operator, records are never returned:
http://localhost:8000/api/tables/invoices/rows?_page=1&_limit=20&_filters=InvoiceDate__lt:2030
These suggest __lt
, __gt
, __lte
and __gte
aren't working properly.
Separately to that, the query parsing is failing if the filter value includes a hyphen, like: 2009-01
.
Expected behavior
I expected the 21 matching records to still be returned