Skip to content

expected string or Sqlizer, not int error when using CASE WHEN with squirrel #388

@liyuan1125

Description

@liyuan1125

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. 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions