Skip to content

Conversation

@dlevy-msft-sql
Copy link
Contributor

@dlevy-msft-sql dlevy-msft-sql commented Jan 25, 2026

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:

  • checkDefaultValue in convertOsArgs injects default value

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
Copy link

Copilot AI left a 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 getOptionalIntArgument to treat an empty flag value as 0 instead of -1.
  • Relaxed normalizeFlags validation for the errors-to-stderr flag to accept an empty value alongside 0 and 1.
  • Added TestErrorsToStderrDefaultValue to exercise -r0/-r1 parsing and ErrorsToStderr wiring.

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
Copy link

Copilot AI left a 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.

Copy link

Copilot AI left a 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.

Copy link

Copilot AI left a 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.

@dlevy-msft-sql dlevy-msft-sql self-assigned this Jan 25, 2026
@dlevy-msft-sql dlevy-msft-sql added sqlcmd switch switch in existing sqlcmd Size: S Small issue (less than one week effort) labels Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: S Small issue (less than one week effort) sqlcmd switch switch in existing sqlcmd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant