fix: remove redundant strings.ToLower in onerrorCommand by dlevy-msft-sql · Pull Request #703 · microsoft/go-sqlcmd

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)