@Suor (as the issue was discovered in the process of using PostgreSQL/sql-bricks-postgres - not sure where a fix if any ought to be applied)
sql(), recommended as a fallback for additional Postgres operations not covered by sql-bricks-postgres, will mangle values where an actual dollar character is desired.
In my case, I wanted to construct queries that do POSIX regular expression matching. The Postgres syntax looks something like:
SELECT * FROM table1 WHERE col1 ~* '.*someregex\d+$' (note the use of $ as an end-of-line anchor in the regex)
In such a case, doing sql.select().from('table1').where(sql("col1 ~* '.*someregex\d+$'")) will replace $ with $1 (in both toString() and toParams()).
Is there any way to escape the $-character to prevent it from being treated as a parameter placeholder? I looked at https://github.com/CSNW/sql-bricks/blob/master/sql-bricks.js#L69 and that line suggests that there isn't one at the moment.
@Suor (as the issue was discovered in the process of using PostgreSQL/sql-bricks-postgres - not sure where a fix if any ought to be applied)
sql(), recommended as a fallback for additional Postgres operations not covered bysql-bricks-postgres, will mangle values where an actual dollar character is desired.In my case, I wanted to construct queries that do POSIX regular expression matching. The Postgres syntax looks something like:
SELECT * FROM table1 WHERE col1 ~* '.*someregex\d+$'(note the use of$as an end-of-line anchor in the regex)In such a case, doing
sql.select().from('table1').where(sql("col1 ~* '.*someregex\d+$'"))will replace$with$1(in bothtoString()andtoParams()).Is there any way to escape the $-character to prevent it from being treated as a parameter placeholder? I looked at https://github.com/CSNW/sql-bricks/blob/master/sql-bricks.js#L69 and that line suggests that there isn't one at the moment.