1

From rails console, running the following gives an unexpected result:

User.where(:id => [1,2]).where(:id => 2).arel.to_sql
 => "SELECT `users`.* FROM `users` WHERE (`users`.`id` IN (1, 2) OR `users`.`id` = 2)"

I'm not expecting that to be an OR.

This example is a very simplified example of a tableless User model I have that defines a method:

def cars
  Car.where(:id => list_of_users_car_ids_not_from_the_database)
end

where Cars are kept in the database. Then later in a controller

current_user.cars.find(params[:id])

(okay, this is also a simplified example, but much more representative of what I'm trying to accomplish)

4

1 回答 1

1

这些消息来源说它在 3.0.3 和 3.0.4 之间中断,但他们已经在 3.0.5 中“修复”了它。

http://www.ruby-forum.com/topic/1089054#new

http://groups.google.com/group/rubyonrails-core/browse_thread/thread/407f746fd1de6636

他们故意“破坏”它(他们正在修复一个错误并认为新行为更好)。不过,它应该在 3.0.5 中恢复。

于 2011-03-15T22:23:33.883 回答