rails/rails — Issue #4037: AR SQL escaping issue
Author: joshk
Created: 2011-12-19 22:04:56+00:00
State: open

Hey Guys,

Using the following code:

Repository.where("repositories.name ~* ? OR repositories.owner_name ~* ?", query, query)

If the query is: josh/
it is outputted as 'josh/'
which escapes the ' and causes:

ActiveRecord::StatementInvalid: PGError: ERROR: invalid regular expression: invalid escape \ sequence : SELECT "repositories".* FROM "repositories" WHERE ("repositories"."last_build_started_at" IS NOT NULL) AND (repositories.name ~* 'cap\' OR repositories

Thanks,

Josh