How to cast ID field to text in squeel query

53 Views Asked by At

I essentially want to perform a LIKE query on a PostgreSQL primary id column for a query generated using Squeel and I don't think Squeel is understanding the syntax I'm giving it. Any ideas?

Active Record

Task.where("(id::text LIKE ?)", "%1%").to_sql
=> "SELECT \"tasks\".* FROM \"tasks\"  WHERE ((id::text LIKE '%1%'))"

Squeel

Task.where{(id::text =~ "%#{criteria}%")}.to_sql
=> "SELECT \"tasks\".* FROM \"tasks\"  WHERE \"id\".\"text\" ILIKE '%criteria%'"
0

There are 0 best solutions below