2

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".

Community
  • 1
  • 1
clemtoy
  • 1,681
  • 2
  • 18
  • 30

1 Answers1

2

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.

Phonolog
  • 6,321
  • 3
  • 36
  • 64