arrays don't work for SQL IN() statement
Reported by Loïc | August 31st, 2007 @ 01:50 PM
I think I found a little bug :
In your example you show that User.select { |m| [1, 2, 3, 4].include? m.id } is translated to "SELECT * FROM users WHERE users.id IN (1, 2, 3, 4)" and that's great.
But now if I assign my array to a variable, as array = [1,2,3], I can't use the variable properly.
Doing the following : User.select {|m| array.include? m.id } will not translate to "SELECT * FROM users WHERE users.id IN (1, 2, 3, 4)" as expected but to "SELECT * FROM users WHERE users.id IN ('--- \n- 2\n- 3\n- 4\n')"
It seems to get the yaml representation of the array.
Comments and changes to this ticket
-
lifo September 1st, 2007 @ 02:46 PM
Attached patch works fine for me. But there might be a better way.
-
Chris Wanstrath September 1st, 2007 @ 03:26 PM
- State changed from new to resolved
Fixed in http://projects.require.errthebl...
Thanks!
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »