Re: [Rails] 3.0.4 change to chained where methods. Documentation?
On 14 February 2011 21:03, Jeremy <jmcnevin@gmail.com> wrote:
> I've noticed a rather insidious 3.0.4 change to the way that chained
> where methods that reference the same attribute are handled. Does
> anyone know where I can find more information about where/when this
> change came in, and the justification for it? I haven't been able to
> find a changelog mentioning this modification.
>
> Essentially, when you chain two where methods together that reference
> the same attribute, the SQL query generated uses an OR on that
> attribute, rather than AND.
>
> Example:
>
> Rails 3.0.3
> State.where(:abbreviation => 'TX').where(:abbreviation => 'NE')
> SQL: SELECT `states`.* FROM `states` WHERE (`states`.`abbreviation` =
> 'TX') AND (`states`.`abbreviation` = 'NE')
>
> Rails 3.0.4
> State.where(:abbreviation => 'TX').where(:abbreviation => 'NE')
> SQL: SELECT `states`.* FROM `states` WHERE (`states`.`abbreviation` =
> 'TX' OR `states`.`abbreviation` = 'NE')
I can confirm I see the same issue on 3.0.4 (not tried on 3.0.3). It
looks like a bug to me.
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home