Skip to content
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

omit comments from commands #548

Merged
merged 1 commit into from
Aug 23, 2024
Merged

omit comments from commands #548

merged 1 commit into from
Aug 23, 2024

Conversation

shueybubbles
Copy link
Collaborator

Fixes #546

Since our sqlcmd doesn't have a real grammar like the ODBC sqlparser we have to special case some aspects of the syntax.
The sqlcmd syntax isn't clearly documented either.

Copy link
Collaborator

@stuartpa stuartpa left a comment

Choose a reason for hiding this comment

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

:shipit:

@LarnuUK
Copy link

LarnuUK commented Aug 23, 2024

The changed file(s) look like they just handle single line comments (though admitted, I "can't read" Go). Would this address comments using the /* ... */ format as well? Such as:

PRINT 1
:QUIT /*This is a test*/

and

PRINT 1
:QUIT /*This is a Test.
        This is a Test.
        This is Test.*/

@shueybubbles
Copy link
Collaborator Author

The changed file(s) look like they just handle single line comments (though admitted, I "can't read" Go). Would this address comments using the /* ... */ format as well? Such as:

PRINT 1
:QUIT /*This is a test*/

and

PRINT 1
:QUIT /*This is a Test.
        This is a Test.
        This is Test.*/

good catch
our sqlcmd isn't built on a modified sql grammar so some of our shortcuts have had consequences like this.
We also have a limitation that : commands fit on a single line which I am not yet able to free up enough time to really fix. I can add /* to the comment removal though.

@shueybubbles
Copy link
Collaborator Author

shueybubbles commented Aug 23, 2024

hmm looks like ODBC sqlcmd doesn't like /* comment */ either

 9:21:14.32 e:\git\go-sqlcmd>"C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\SQLCMD.EXE" -S davidshi-2019
1> :xml /*foo*/ ON
Sqlcmd: Error: Syntax error at line 1 near command ':xml'.
1> :xml /* foo */ ON
Sqlcmd: Error: Syntax error at line 2 near command ':xml'.
1> :xml ON
1> :xml ON /* on */
Sqlcmd: Error: Syntax error at line 4 near command ':xml'.
1> :quit /*comment*/
Sqlcmd: Error: Syntax error at line 6 near command ':quit'.

@shueybubbles shueybubbles merged commit 0221d93 into main Aug 23, 2024
6 checks passed
@shueybubbles shueybubbles deleted the shueybubbles/546 branch August 23, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

:SETVAR with a comment on the same line throws syntax error
3 participants