I have a table called inbox_messages
with following rows:
user_id message_id
======= ==========
4 8
4 1
4 7
0 9
0 10
0 11
0 12
The table maps to the following model:
class InboxMessage < ActiveRecord::Base
end
When I invoke the find
method with a IN
caluse, I get different resultset depending on the position
of the parameters.
InboxMessage.find(:all, :conditions => [ "user_id IN (?)", "0,4"]) # 8 rows
InboxMessage.find(:all, :conditions => [ "user_id IN (?)", "4,0"]) # 3 rows
Second call above, returns 3 rows instead of 8. Other scenarios works fine, i.e.
InboxMessage.find(:all, :conditions => [ "user_id IN (0, 4)" ]) # 8 rows
InboxMessage.find(:all, :conditions => [ "user_id IN (4, 0)" ]) # 8 rows
InboxMessage.find(:all, :conditions => [ :user_id => [0, 4] ]) # 8 rows
InboxMessage.find(:all, :conditions => [ :user_id => [4, 0] ]) # 8 rows