Skip to content

Commit 6ea05eb

Browse files
Fix review comments for PR microsoft#637
- Add validation that --no-bom requires -u (Unicode output file) - Add test case for --no-bom validation
1 parent 5e0a81e commit 6ea05eb

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

cmd/sqlcmd/sqlcmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ func (a *SQLCmdArguments) Validate(c *cobra.Command) (err error) {
172172
err = rangeParameterError("-t", fmt.Sprint(a.QueryTimeout), 0, 65534, true)
173173
case a.ServerCertificate != "" && !encryptConnectionAllowsTLS(a.EncryptConnection):
174174
err = localizer.Errorf("The -J parameter requires encryption to be enabled (-N true, -N mandatory, or -N strict).")
175+
case a.NoBOM && !a.UnicodeOutputFile:
176+
err = localizer.Errorf("The --no-bom parameter requires -u (Unicode output file).")
175177
}
176178
}
177179
if err != nil {

cmd/sqlcmd/sqlcmd_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ func TestValidateFlags(t *testing.T) {
220220
{[]string{"-a", "100"}, "'-a 100': Packet size has to be a number between 512 and 32767."},
221221
{[]string{"-h-4"}, "'-h -4': header value must be either -1 or a value between 1 and 2147483647"},
222222
{[]string{"-w", "6"}, "'-w 6': value must be greater than 8 and less than 65536."},
223+
{[]string{"--no-bom"}, "The --no-bom parameter requires -u (Unicode output file)."},
223224
}
224225

225226
for _, test := range commands {

0 commit comments

Comments
 (0)