#915 ✓resolved

Chained finders being isolated

Reported by ash.gti | June 20th, 2009 @ 08:46 PM | in 0.10.0

Currently in both 0.9.11 and 0.10.0 if you try to chain a finder it does not isolate the queries.

For instance, if you did

Model.all(:count.gt => 5).all(:conditions => ['name != ? OR name != ?', 'Joe', 'Steve'])

You'd expect there WHERE to be close to:

SELECT * FROM model WHERE (count > 5) AND (name != 'Joe' OR name != 'Steve')

However, currently the query would look like:

SELECT * FROM model WHERE count > 5 AND name != 'Joe' OR name != 'Steve'

and clearly in that query the OR statement needs parenthesis around it or else your going to get results you wouldn't normally expect. This issue doesn't really crop up unless you have an OR in your query, but I think its still an issue.

Here is a gist that I hope clearly demonstrates the issue: http://gist.github.com/133351

Comments and changes to this ticket

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket


Referenced by