Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db.Raw slice arguments that have fewer than 2 elements pass invalid query parameters #279

Closed
c2h5oh opened this issue Oct 20, 2016 · 0 comments

Comments

@c2h5oh
Copy link
Contributor

c2h5oh commented Oct 20, 2016

Consider 3 examples:

  1. []int64 with 2 elements as argument .OrderBy(db.Raw("CASE WHEN id IN ? THEN 0 ELSE 1 END", []int64{1000, 2000})
  2. []int64 with 1 element as argument .OrderBy(db.Raw("CASE WHEN id IN ? THEN 0 ELSE 1 END", []int64{1000})
  3. []int64 with 0 elements as argument .OrderBy(db.Raw("CASE WHEN id IN ? THEN 0 ELSE 1 END", []int64{})

All 3 generate the same, correct SQL:
ORDER BY CASE WHEN id IN $3 THEN 0 ELSE 1 END

1st example is correct and works

2nd example passes the only element of the slice instead of the slice

3rd example does not pass the argument at all

xiam added a commit that referenced this issue Oct 21, 2016
@xiam xiam closed this as completed in #281 Oct 21, 2016
xiam pushed a commit that referenced this issue Oct 21, 2016
Fix handling of slice parameters. Closes #279
xiam pushed a commit that referenced this issue Nov 24, 2016
Fix handling of slice parameters. Closes #279
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

No branches or pull requests

1 participant