Skip to content

fix: expand slice args in raw Where/Expr placeholders - #399

Open
Solaris-star wants to merge 1 commit into
Masterminds:masterfrom
Solaris-star:fix/383-where-raw-slice-expand
Open

fix: expand slice args in raw Where/Expr placeholders#399
Solaris-star wants to merge 1 commit into
Masterminds:masterfrom
Solaris-star:fix/383-where-raw-slice-expand

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

Where("id NOT IN ?", []int{1,2,3}) previously bound the slice as a single argument, producing invalid SQL:

WHERE id NOT IN ?
-- args: [[1 2 3]]

Eq/NotEq helpers already expand list values into (?,?,?).

Fix

Route raw string predicates through Expr expansion, and teach Expr.ToSql to expand array/slice arguments into parenthesized placeholders (matching Eq/NotEq).

Test plan

  • go test .
  • TestExprListArgExpansion
  • TestWhereRawSQLListArgExpansion

Fixes #383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Where with raw sql string and slice arg

1 participant