Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added initial stab at an or scope operator #6817

Closed
wants to merge 2 commits into from
Closed

Conversation

loz
Copy link

@loz loz commented Jun 21, 2012

This includes a test case and an implementation. I think I need some advice however as the only way I could replace the where clauses in a scope was to unscope, which will have killed other aspects, like having etc, so I'm happy to make changes if someone could advice.

@emilecantin
Copy link

This fixes #5545. Thanks!

@daniel2d2art
Copy link

Fantásticooow!!
We need it!
Thx

# # SELECT * FROM users WHERE name = 'Alice' OR email = 'joe@example.com'
#
def or(scope)
left = self.where_values.inject {|l,r| l.and(r)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this particular line makes the assumption that .and is always the 'join' for clauses. This is true until now, but if one had a scope with or joining to another scope with ors, they'd end up ands.

If there's an arel 'join clauses' method which would use correct concat here that would be handy. If not, a hint at where to find the concat used in the where to extract a method here to do it would be good.

@daniel2d2art
Copy link

Hi Loz,
using unscope, are you disabling too, joins, selects and other scope setings? nops?

@loz
Copy link
Author

loz commented Jun 22, 2012

Yup, this is totally NOT the solution I want, which is why I put it up for some feedback.

@steveklabnik
Copy link
Member

Hey @loz! Do you plan to continue to work on this?

@steveklabnik
Copy link
Member

Hey @loz! it's been a month since I've heard from you, so I'm giving this a close. If you'd like to keep up with this pull, push some more commits, and I'll gladly re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants