refactor: simplify the escapeIdentifier logic

This commit is contained in:
Gajus Kuizinas 2018-07-29 21:29:27 +01:00
parent 6c840aabb0
commit 00d749cdfa

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