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

Variable substitution not disabled when using -x #541

Closed
grothwell opened this issue Jul 11, 2024 · 3 comments
Closed

Variable substitution not disabled when using -x #541

grothwell opened this issue Jul 11, 2024 · 3 comments

Comments

@grothwell
Copy link

In go-sqlcmd 1.7.0 the -x parameter doesn't appear to be working and leads to an error. Running the same script using ODBC sqlcmd works properly.

testsql.sql contents:
SELECT '$('

Example command usage:
sqlcmd -i testsql.sql -x

Example output when not working:
Sqlcmd: Error: Syntax error at line 1

@shueybubbles
Copy link
Collaborator

thx for opening the issue! I suspect we only check -x after finding variable placeholders instead of skipping the variable scan altogether.

@grothwell
Copy link
Author

grothwell commented Jul 12, 2024

I did a quick local check and found DisableVariableSubstitution was being set to true when -x was present. The bug is likely in the implementation of how DisableVariableSubstitution is used. I did not trace it any further than that.

As far as I could tell there is no escape character for $(. My work around is to do character substitution in the script before running sqlcmd to avoid the error caused by sqlcmd finding $( in the sql script.

My actual case is a script that is inserting Javascript in the field of a table. I simplified the example in my issue report.

@shueybubbles
Copy link
Collaborator

try 1.8

thx!

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

No branches or pull requests

2 participants