LeX
LeX

Reputation: 101

Activerecord regex search with mass_assignment_sanitizer = :strict

I want to perform following search request

.where("url REGEXP ?", '^/gallery/\d+')

but sanitizer spoils expression and i get this:

^/gallery/\\\\d+

how force skip sanitizing for this condition?

Upvotes: 0

Views: 304

Answers (1)

phoet
phoet

Reputation: 18845

the whole point about using ? in where conditions is to sanitize the string.

if you are using database specific queries, it's always a good idea to mention it in your tags. i assume that you want to use the MySQL REGEXP function.

if you don't want it to be sanitized just write this: where("url REGEXP '^/gallery/\d+'")

Upvotes: 1

Related Questions