Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only order?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!reservedWords.includes(str) && identifierRegexp.test(str)) return str;
return '`' + str + '`';

quote = '`';
} else if (identifierRegexp.test(str)) return str;
return quote + str + quote;
};

Expand Down Expand Up @@ -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);
Expand Down