squirrel
squirrel copied to clipboard
fix: support non-string values in Case When/Then/Else clauses
Fixes #388
Problem
Passing non-string, non-Sqlizer values (like integers) to Case().When() or .Else() fails with:
expected string or Sqlizer, not int
This makes it impossible to use CASE WHEN with numeric values:
sq.Case("order_no").
When("'ORD001'", 500). // ← fails: 500 is int
Else(0) // ← fails: 0 is int
Fix
In part.ToSql(), treat non-string, non-Sqlizer values as parameterized arguments (using ? placeholder) instead of returning an error. This is consistent with how other parts of squirrel handle arbitrary values.
Before: "expected string or Sqlizer, not int" error
After: CASE order_no WHEN 'ORD001' THEN ? ELSE ? END with args [500, 0]
All existing tests pass.