alibaba / nquery

Generic SQL engine for Web and Big-data.
381 stars 117 forks source link

Add support with escaped FROM #19

Open ghost opened 6 years ago

ghost commented 6 years ago

If there is an escaped table in the FROM statement it throws an error.

Example:

var parse = require('node-sqlparser').parse;
var stringify = require('node-sqlparser').stringify;

// ERROR
var sql = 'SELECT `id` FROM `Tb`'; // escaped `Tb`
var astObj = parse(sql); // ERROR

// OK
var sqlOK = 'SELECT `id` FROM Tb';
var astObjOK = parse(sql); // OK

Example of the error:

      throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
      ^
SyntaxError: Expected "$", WHITE_SPACE or [A-Za-z_] but "`" found.