Skip to content

fix: remove redundant strings.ToLower in onerrorCommand - #703

Open
David Levy (dlevy-msft-sql) wants to merge 1 commit into
microsoft:mainfrom
dlevy-msft-sql:fix-redundant-tolower
Open

David Levy (dlevy-msft-sql) wants to merge 1 commit into
microsoft:mainfrom
dlevy-msft-sql:fix-redundant-tolower

Conversation

@dlevy-msft-sql

Copy link
Copy Markdown
Contributor

Problem

The onerrorCommand function has redundant code that makes the codebase harder to read.

Root Cause

strings.EqualFold is already case-insensitive, so wrapping the first argument with strings.ToLower() is unnecessary.

Code Change

Before:

if strings.EqualFold(strings.ToLower(params), "exit") {
    s.Connect.ExitOnError = true
} else if strings.EqualFold(strings.ToLower(params), "ignore") {

After:

if strings.EqualFold(params, "exit") {
    s.Connect.ExitOnError = true
} else if strings.EqualFold(params, "ignore") {

Testing

  • Build passes: go build ./...
  • TestOnErrorCommand passes with live database connection (10.0.0.8)
@dlevy-msft-sql David Levy (dlevy-msft-sql) added this to the v1.9.2 milestone Apr 16, 2026
strings.EqualFold is already case-insensitive, making the
ToLower call unnecessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant