From 69e3ca944348ddba56f06d9cb4939a325f93e94f Mon Sep 17 00:00:00 2001 From: burtontanner Date: Fri, 15 Jun 2018 13:20:43 -0600 Subject: [PATCH 1/2] this will now allow keyword tables like --- utilities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utilities.js b/utilities.js index b59a440..951a650 100644 --- a/utilities.js +++ b/utilities.js @@ -482,8 +482,8 @@ const introspection = (connection) => { // connection.fields = function(table, callback) { this.queryHash( - 'SHOW FULL COLUMNS FROM ' + - escapeIdentifier(table), [], + 'SHOW FULL COLUMNS FROM `' + + escapeIdentifier(table) +'`', [], (err, res) => { if (err) res = false; callback(err, res); From 33b377895dd18476762dae85340d728aced0aa77 Mon Sep 17 00:00:00 2001 From: burtontanner Date: Mon, 18 Jun 2018 12:47:43 -0600 Subject: [PATCH 2/2] the back tick is not is the escapeIdentifier function. Npm test is working again :) --- utilities.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utilities.js b/utilities.js index 951a650..a5caddf 100644 --- a/utilities.js +++ b/utilities.js @@ -4,7 +4,9 @@ const identifierRegexp = /^[0-9,a-z,A-Z_.]*$/; const escapeIdentifier = (str, quote) => { quote = quote || '`'; - if (identifierRegexp.test(str)) return str; + if (str === 'order') { + quote = '`'; + } else if (identifierRegexp.test(str)) return str; return quote + str + quote; }; @@ -482,8 +484,8 @@ const introspection = (connection) => { // connection.fields = function(table, callback) { this.queryHash( - 'SHOW FULL COLUMNS FROM `' + - escapeIdentifier(table) +'`', [], + 'SHOW FULL COLUMNS FROM ' + + escapeIdentifier(table), [], (err, res) => { if (err) res = false; callback(err, res);