When I try to use the CASE WHEN statement with squirrel to update a column based on multiple conditions, I get the following error:
expected string or Sqlizer, not int
package main
import (
"fmt"
sq "github.com/Masterminds/squirrel"
)
func main() {
amountExpr := sq.Case("order_no").
When("ORD001", 500).
When("ORD002", 600)
sql, _, err := sq.Update("orders").
Set("amount", amountExpr).
Where(sq.Eq{"order_no": []string{"ORD001", "ORD002", "ORD003"}}).
ToSql()
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("Generated SQL:", sql)
}
Thank you! 🙏 Would appreciate any insights or guidance on this issue. 😊