-
Notifications
You must be signed in to change notification settings - Fork 79
Allow -r without argument, defaulting to 0 #635
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
base: main
Are you sure you want to change the base?
Conversation
ODBC sqlcmd allows -r without an explicit value, defaulting to 0 (enable stderr redirection for severity >= 11). Previously go-sqlcmd required -r0 or -r1 explicitly. Changes: - normalizeFlags: Accept empty value for -r flag - getOptionalIntArgument: Return 0 for empty value instead of -1 - Add TestErrorsToStderrDefaultValue test
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.
Pull request overview
This PR aims to make the legacy sqlcmd CLI accept -r without an explicit value, defaulting to 0 (redirecting severity ≥ 11 errors to stderr) for parity with ODBC sqlcmd. It updates integer flag parsing and normalization around errors-to-stderr and introduces a dedicated test to validate -r behavior.
Changes:
- Updated
getOptionalIntArgumentto treat an empty flag value as0instead of-1. - Relaxed
normalizeFlagsvalidation for theerrors-to-stderrflag to accept an empty value alongside0and1. - Added
TestErrorsToStderrDefaultValueto exercise-r0/-r1parsing andErrorsToStderrwiring.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/sqlcmd/sqlcmd.go | Adjusts optional int parsing and errors-to-stderr normalization to accommodate (intended) empty-value handling for -r. |
| cmd/sqlcmd/sqlcmd_test.go | Adds a new test for -r0/-r1 behavior and continues to exercise sqlcmd flag parsing and validation. |
- Remove dead code: empty string case in errorsToStderr switch (unreachable due to early return) - Add test for bare -r flag without argument to verify it defaults to 0
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
ODBC sqlcmd allows -r without an explicit value, defaulting to 0 (enable stderr redirection for severity >= 11 errors). Previously go-sqlcmd required -r0 or -r1 explicitly.
Changes: