-
Notifications
You must be signed in to change notification settings - Fork 79
Add --no-bom flag for ODBC sqlcmd compatibility #637
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
By default, -u (unicode output) includes a UTF-16 LE BOM (FF FE) at the start of output files. ODBC sqlcmd does not write a BOM. This adds --no-bom flag to omit the BOM when strict ODBC compatibility is needed. Usage: sqlcmd -u --no-bom -o output.txt Changes: - Add NoBOM field to SQLCmdArguments and Sqlcmd structs - Add --no-bom flag with descriptive help - Conditionally use unicode.IgnoreBOM when flag is set - Update README to document the difference and new flag - Add TestUnicodeOutputNoBOM 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 adds a --no-bom flag to provide ODBC sqlcmd compatibility by omitting the UTF-16 Little-Endian BOM from Unicode output files. By default, when using -u (unicode output), go-sqlcmd writes a BOM (bytes FF FE) to output files, but ODBC sqlcmd does not. The new flag allows users to suppress the BOM when strict ODBC compatibility is needed.
Changes:
- Added
NoBOMfield to theSqlcmdstruct andSQLCmdArgumentsstruct to control BOM behavior - Updated the output file encoding logic to conditionally omit the BOM based on the flag
- Added test coverage to verify the BOM is correctly omitted when
--no-bomis used - Updated README documentation to explain the difference from ODBC sqlcmd and the new flag
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/sqlcmd/sqlcmd.go | Added NoBOM boolean field to the Sqlcmd struct to control BOM output |
| pkg/sqlcmd/commands.go | Updated outCommand to use unicode.IgnoreBOM when NoBOM is true, otherwise uses unicode.UseBOM |
| cmd/sqlcmd/sqlcmd.go | Added NoBOM field to SQLCmdArguments, registered the --no-bom CLI flag, and passed the value to the Sqlcmd struct |
| cmd/sqlcmd/sqlcmd_test.go | Added TestUnicodeOutputNoBOM test to verify BOM is not written when flag is set |
| README.md | Updated documentation to explain that -u includes a BOM by default and how to use --no-bom for ODBC compatibility |
- Add validation that --no-bom requires -u (Unicode output file) - Add test case for --no-bom validation
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 5 out of 5 changed files in this pull request and generated 1 comment.
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 5 out of 5 changed files in this pull request and generated 1 comment.
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 5 out of 5 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 5 out of 5 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 5 out of 5 changed files in this pull request and generated no new comments.
By default, -u (unicode output) includes a UTF-16 LE BOM (FF FE) at the start of output files. ODBC sqlcmd does not write a BOM. This adds --no-bom flag to omit the BOM when strict ODBC compatibility is needed. Usage: sqlcmd -u --no-bom -o output.txt. Also updates README to document the difference.