Merge pull request #1701 from gajus/issue-1699

refactor: simplify the escapeIdentifier logic
This commit is contained in:
Charmander 2018-07-30 02:46:22 +00:00 committed by GitHub
commit e7602bc678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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