简体   繁体   中英

Node.js PostgreSQL single quote issue with prepared query

I have an issue with an INSERT query in PostgreSQL and Node.js

It looks like values containing a single quote like "L'Ange" isn't passing through the query :

connection.query('insert into my_table (name) select $1', {name : "L'ange"}, function ...

Error

[error: syntax error at or near "Ange"]

Any idea ?

I already tried, various sql escapes, even the npm module "pg-escape", nothing works... Thanks !

你总是可以通过将它加倍来逃避单引号

connection.query('insert into my_table (name) select $1', {name : "L''ange"}, function ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM