Flask-Restless case-insensitive query

317 Views Asked by At

How to make case-insensitive search query using Flask-Restless?

Example:

api/user?q={"filters":[{"name":"lastname","op":"like","val":"%davidson%"}]}

I would like the previous code to return "davidson", "Davidson", "DAVIDSON"... But it only returns "davidson".

1

There are 1 best solutions below

0
Phonolog On BEST ANSWER

You can use the ilike operator like so:

api/user?q={"filters":[{"name":"lastname","op":"ilike","val":"davidson"}]}

This is not really documented in the Flask-Restless docs, but the operator is documented in SQLAlchemy which is the OR mapper Flask-Restless uses under the hood. See the relevant docs here or this answer.