Join GitHub today
Proper string-escapes for Postgres #1548
Currently, knex tries to use backslashes to escape various characters in string literals for Postgres. The problem is, that Postgres doesn't interpret slashes in string literals by-default since version 9.1. It is possible to enable interpretation by setting
Strictly speaking, usage of regular string-literals is just not a predictable option anymore.
The proper solution is: use non-standard
So I'll just open up your example a bit to understand it better... Input
But it is true that knex also has its own escaping function, which should work correctly. Which currently indeed replaces \ with \
> knex('dodo').where('name', 'hell\\"o there').toString() 'select * from "dodo" where "name" = \'hell\\\\"o there\''
Which really seem to result invalid string in database (too many backslashes...):
So... we seem to need own string escaping function for postgres or change some other part of string literal interpolation to use E'' literals.
ps. also how