From 00d749cdfa62c483a2327d68f57eac1ebdbe10c4 Mon Sep 17 00:00:00 2001 From: Gajus Kuizinas Date: Sun, 29 Jul 2018 21:29:27 +0100 Subject: [PATCH] refactor: simplify the escapeIdentifier logic --- lib/client.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/client.js b/lib/client.js index 3228571d5..0d023db7c 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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