mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Merge pull request #1701 from gajus/issue-1699
refactor: simplify the escapeIdentifier logic
This commit is contained in:
commit
e7602bc678
@ -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