On 16 February 2011 09:44, Colin Law <[email protected]> wrote:
> On 16 February 2011 05:42, Mark Kremer <[email protected]> wrote:
>> It may seem a bit odd with the where method chained twice like that, but the
>> query with the OR (Rails 3.0.4) will probably get you the result you want
>> whereas the query with the AND (Rails 3.0.3) will return 0 records at all
>> times (because the same attribute can't have two values).
>
> I disagree that OR is the result one would want if one were to code
> this.  I agree it is apparently a useless query and obviously one
> would not code it exactly like this.  If the sql for this is
> incorrectly generated however, it is likely that a more subtle, and
> useful, query may also be encoded wrongly.  The principle of chained
> where is that the first one is performed, then the next is performed
> on the results of the first.  At least that is how I understand it.
>
> Consider:
> State.where(:abbreviation =>  'TX').where("abbreviation =  'NE'")
> This (correctly in my view) uses AND in the query.
> As 3.0.4 stands at the moment the above yields a different result to
> State.where(:abbreviation =>  'TX').where(:abbreviation =>  'NE')
> which seems incorrect to me.
>
> I will post on rails-core to see what the response is there.

I posted to rails-core and apparently it is by design rather than a
bug.  The question seems to have stirred up a bit of a furore however,
see 
http://groups.google.com/group/rubyonrails-core/browse_thread/thread/407f746fd1de6636

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to