Case insensitive query with Lucid (PostgresSQL) #1449
-
Hey! I'm using PostgresSQL, and I'm trying to do a case insensitive where. Here is what would work for MySQL: A common solution on a raw query would be to do: I got around the problem using Regular Expressions, but I really don't like the looks of it, and there is probably a better way to do it. Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Nope, raw queries are equally safe. You just need to use bind parameters when defining a raw where clause. Infact, the core of the framework uses the |
Beta Was this translation helpful? Give feedback.
-
Since you're using PostgreSQL you could use the insensitive operator ilike:
|
Beta Was this translation helpful? Give feedback.
Since you're using PostgreSQL you could use the insensitive operator ilike:
query.where('name', 'ilike', '%${term}%')