-
Notifications
You must be signed in to change notification settings - Fork 68
Fix piping query without go
command into sqlcmd-go
#583
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
Conversation
Co-authored-by: shueybubbles <[email protected]>
go
command into sqlcmd-go returns nothinggo
command into sqlcmd-go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding the stdin detection code in the run func, let's change |
…eractive status Co-authored-by: shueybubbles <[email protected]>
Implemented the suggested change. I've updated |
Co-authored-by: shueybubbles <[email protected]>
Issue
When piping a SQL query to sqlcmd-go without a
GO
statement, the query was read but not executed, returning no output. However, the ODBC version of sqlcmd does execute these queries.For example:
Root Cause
The issue was in the
run
function incmd/sqlcmd/sqlcmd.go
. When input is coming from stdin in non-interactive mode, theprocessAll
parameter was always set tofalse
. This meant that when EOF was reached, if there was no explicitGO
statement, the query would not be executed.Solution
The fix detects when stdin is a pipe (not an interactive terminal) and sets
processAll=true
in that case, which executes the query when EOF is reached:This minimal change ensures that sqlcmd-go behaves like the ODBC version when receiving piped input, executing queries without requiring a
GO
statement.Fixes #581.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
someserver
/tmp/go-build689818603/b001/sqlcmd.test -test.testlogfile=/tmp/go-build689818603/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.