Closed a1ea321 closed 3 months ago
Good day @a1ea321
For you the fix takes twenty minutes, for me two days.
Yes, you only work on a fix if you love it. Submitting an issue is the fastest way to improve the parser. Faster for you because I know how to fix it. Faster for me because you already know what's wrong.
Here is the fix: https://github.com/klahnakoski/mo-sql-parsing/commit/abf05d6481eed14dd3a147a811eb7cd9945cabb6
The DECLARE
only works inside the context of a function/procedure
Thank you for the fix. (It took me a while to see.)
My real world example is still not working. I checked this page and realized there's more to this issue: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/declare-local-variable-transact-sql?view=sql-server-ver16 Then I added two more tests: PR
There's another case for which I couldn't think of the proper syntax tree, so here's the query:
DECLARE @MYTABLEVAR TABLE (id_col INT PRIMARY KEY);
results in:
mo_parsing.exceptions.ParseException: Expecting {unsigned} | {zerofill} | {column_options} | {StringEnd} | {lb} | {as}, found "= 42;" (at char 24), (line:1, col:25)
pip show mo-sql-parsing
saysVersion: 10.627.24135
By the way, I'd be honored to submit a fix so I tried. But I got lost around
ParseException.bestCause
. These two possibilities discourage me:DECLARE
statements are intentionally not parsed. My work would be pointless.