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

Unable to pass slice of int to dbx.In() #60

Closed
byanjiong opened this issue Feb 5, 2018 · 4 comments
Closed

Unable to pass slice of int to dbx.In() #60

byanjiong opened this issue Feb 5, 2018 · 4 comments

Comments

@byanjiong
Copy link

When passing []int to dbx.In(), the compiler give error as such:

sql: converting argument $3 type: unsupported type []int, a slice of int

How can I pass a slice in the dbx.In()?

numberList := []int{ 1, 2, 3}
err = rs.Tx().Select().Where(dbx.And(dbx.HashExp{"creator": rs.UserID(), "status": "a"}, dbx.In("role", numberList ))).OrderBy("modified").All(&customer)

tried ->

  • dbx.In("role", numberList)
  • dbx.In("role", numberList...)

can't really get it done... may please advise...

@qiangxue
Copy link
Member

qiangxue commented Feb 5, 2018

It should be dbx.In("role", numberList...)

@byanjiong
Copy link
Author

A snapshot of my dbx usage. It works well until I use the dbx.In() together with []int. May try to have a look? :)

Anyway, a very very good package... user friendly x1000...

image

@qiangxue
Copy link
Member

qiangxue commented Feb 5, 2018

I see. I think this is how Go works. You need to declare your numberList to be []interface{}.

@byanjiong
Copy link
Author

Yes, it works by declaring []interface. Thank you...

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

2 participants