8000 omit comments from commands by shueybubbles · Pull Request #548 · microsoft/go-sqlcmd · GitHub
[go: up one dir, main page]

Skip to content

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
@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

4 participants

0