Skip to content

Column names with >1 apostrophe not escaped correctly in .query() #934

@jkgeyti

Description

@jkgeyti

Column names with >1 apostrophe not escaped correctly in .query():

var pg = require('pg'); // version 4.4.4 var conString = "postgres://..."; // pg.connect(conString, function(err, client, done) {  // client.query("CREATE TABLE atable ( \"column''name\" TEXT )"); // }); pg.connect(conString, function(err, client, done) { client.query("SELECT * FROM atable"); });
$ node bug.js undefined:4 this['column\''name'] = rowData[0] == null ? null : parsers[0](rowData[0]); ^^^^ SyntaxError: Unexpected token ILLEGAL at Function (native) at Result.addFields (.../node_modules/pg/lib/result.js:98:20) at Query.handleRowDescription (.../node_modules/pg/lib/query.js:54:16) at null.<anonymous> (.../node_modules/pg/lib/client.js:103:24) at emitOne (events.js:77:13) at emit (events.js:169:7) at Socket.<anonymous> (.../node_modules/pg/lib/connection.js:109:12) at emitOne (events.js:77:13) at Socket.emit (events.js:169:7) at readableAddChunk (_stream_readable.js:146:16) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions