-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSQL: GO
falsely identify as column_alias
?
#3275
Comments
It seems that SQL Server parses it as one batch. Results of execute:
Here
|
Thanks, @speshuric, for your swift response! Again maybe just me, but I seem to get the same "issue" even with a line break?
Hmm, on my DB server with MSSQL - Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64) - I get the following output: Is there a good way to check what is contained in one batch? I can only think of smth like Sorry, maybe I miss smth fundamental here... |
Let's separate the issues. The first of all ms says "GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor." The second moment to note is that indeed it seems grammar in this repo is not correct about dividing file to batches by GO-statements. But there is workaround. You can just use semicolon to help parser separate SELECTs:
Parsed as: The last thing I have to note, there is no full open specification for T-SQL, so all third party implementations including this one should deal with this sadly fact. |
- '\NGO' not recognized for simple SELECT statements, see antlr/grammars-v4#3275 - New grammar has more false positives; hence, some invalid queries are flagged as valid
@speshuric, thanks so much!
Yes, indeed. I've changed it now accordingly. |
#newbie
What happened:
I'm trying to parse:
SELECT 'a' GO SELECT 'b'
Expected: two batches
Actual: parsed within one batch
Being a newbie, it seems that the substring "GO" is wrongly parsed within the rule
column_alias
while it's protected.The parse tree
![image](https://user-images.githubusercontent.com/1476077/225990443-83d446df-5f05-4ffd-8f3f-4289cd80a27c.png)
The text was updated successfully, but these errors were encountered: