Support ESCAPE clause #166

wants to merge 1 commit into

3 participants


Added Arel::Nodes::Escape to escape special characters (% or _) in LIKE pattern.

# Usage
table =
query = table.project relation[:id]

escaped_pattern ='%100!% fruit juice', '!')
query.where relation[:name].matches(escaped_pattern)
# => SELECT "drinks"."id" FROM "drinks" WHERE "drinks"."name" LIKE '%100!% fruit juice' ESCAPE '!'

I like this. Should we also allow an optional argument for matches and matches_any, so it can be chained correctly:

relation[:name].matches('%100!% fruit juice', '!')
relation[:name].matches_any(['%100!% fruit juice', '%10!% sales tax'], '!')
Ruby on Rails member

IMHO, this is more like a third attribute of a Matches, rather than a distinct node in its own right

@matthewd matthewd closed this in #318 Sep 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment