'Using named placeholders in queries and PSQL's :alnum: at the same time
I wanted to improve a query I have in activerecord using named placeholders because I use the same variables several times.
The problem I have is that in the same query I use PSQL's :alnum: like:
regexp_replace(name, '[^[:alnum:] .-]', '', 'g')) ...
Executing this yields the error: ActiveRecord::PreparedStatementInvalid (missing value for :alnum in SELECT)
In other words, Rails thinks that :alnum is a named placeholder. But it isn't, it's a PostgreSQL 's keyword, so my question is:
How can I use named placeholders in queries and PSQL's :alnum: at the same time?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
