mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
refactor: simplify the escapeIdentifier logic
This commit is contained in:
parent
6c840aabb0
commit
00d749cdfa
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user