joereynolds / sql-lint

An SQL linter
MIT License
427 stars 41 forks source link

Unable to categorise query for sql keyword GRANT #168

Open deeagle opened 3 years ago

deeagle commented 3 years ago

It seems that sql-lint is unable to parse GRANT keyword.

Query

GRANT SELECT ON myschema.* TO 'username'@'%';

Error

/node_modules/sql-lint/dist/src/lexer/lexer.js:14
    throw new Error(`Unable to categorise query: ${query}. The query must start with one of ${Object.keys(keywords_1.Keyword)}`);
    ^
Error: Unable to categorise query: grant select on myschema.* to 'username'@'%';. The query must start with one of Alter,Begin,Call,Create,Declare,Delete,Delimiter,Drop,Else,End,From,Having,If,Insert,Join,Leave,Limit,Replace,Return,Select,Set,Show,Truncate,Update,Use,Where,CommentHash,CommentDash,CommentMultiLineStart,CommentMultiLineEnd,Newline,WindowsNewline
    at Object.categorise (/node_modules/sql-lint/dist/src/lexer/lexer.js:14:11)
    at /node_modules/sql-lint/dist/src/checker/checkerRunner.js:38:42
    at Array.forEach (<anonymous>)
    at CheckerRunner.run (/node_modules/sql-lint/dist/src/checker/checkerRunner.js:35:20)
    at Object.<anonymous> (/node_modules/sql-lint/dist/src/main.js:86:8)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)]

Environment

zorion79 commented 3 years ago

Please, add word grant

joereynolds commented 3 years ago

Hi all, sorry for the delay, this is in the pipeline for the next release. I've done a big refactor so it can better handle different database systems, thanks for the patience!