Skip to content

Commit

Permalink
Merge pull request #1701 from gajus/issue-1699
Browse files Browse the repository at this point in the history
refactor: simplify the escapeIdentifier logic
  • Loading branch information
charmander committed Jul 30, 2018
2 parents 6c840aa + 00d749c commit e7602bc
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions lib/client.js
Expand Up @@ -305,20 +305,7 @@ Client.prototype.getTypeParser = function (oid, format) {

// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
Client.prototype.escapeIdentifier = function (str) {
var escaped = '"'

for (var i = 0; i < str.length; i++) {
var c = str[i]
if (c === '"') {
escaped += c + c
} else {
escaped += c
}
}

escaped += '"'

return escaped
return '"' + str.replace(/"/g, '""') + '"'
}

// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
Expand Down

0 comments on commit e7602bc

Please sign in to comment.