Skip to content

omit comments from commands - #548

Merged
David Shiflet (shueybubbles) merged 1 commit into
mainfrom
shueybubbles/546
Aug 23, 2024
Merged

David Shiflet (shueybubbles) merged 1 commit into
mainfrom
shueybubbles/546

Conversation

@shueybubbles

Copy link
Copy Markdown
Contributor

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.

@stuartpa Stuart Padley (stuartpa) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:shipit:

@LarnuUK

Thom A (LarnuUK) commented Aug 23, 2024 •

Copy link
Copy Markdown

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
Copy Markdown
Contributor 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

David Shiflet (shueybubbles) commented Aug 23, 2024 •

Copy link
Copy Markdown
Contributor Author

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
David Shiflet (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

3 participants