Last Updated: February 25, 2016
·
1.586K
· kaznum

SQL92 LIKE expression escaping in Arel's matches(_all) method

Escape some special character in "LIKE" in where-expression with Arel.

When there are some "%" in str in

where(Item.arel_table[:name].matches("%#{str}%"))

"%" in str should be escaped.

The following snipet escapes this kind of special characters by SQL92 convention.

https://gist.github.com/3656283