Scopes with OR and AND optional chainity discussion

We have wanted similar, and resorted to getting where’s out of arel.

I thought about the following syntax:

MyModel.somescope.or(something_which_is_a_scope_chain_too)

Yes I think some chainity_operator method like you say, can works ok too.

I have raised a pull request which gets this started, though there’s feedback required for sure:

https://github.com/rails/rails/pull/6817

Maybe I've missed it, but how do you define precedence between the usual AND's and now OR's? Chaining a bunch of AND's will always results in the same result, but add OR to the mix and now you're complicating things unless you're a lot more explicit with the conditions.

We're following to using disjunction on two or more chained scopes. This scopes can continue use custom logical conditions. Normal would be to use parentheses between on query. In pro of DRY some cases we need use scopes conected as AND but in another cases we need to use OR connections. Rails only do scope chain with AND. Some times you need to rewritte a full functionality of one or more scoper only for use OR connections.

Wow yep! I'hope this prosperes ... I'm not sure next step for consolidation on RoR version. Thanks Loz

I believe that the arel implementation leads to brackets around left and right sides of the or. This can be checked by using my branch and doing .to_sql on any scope chain produced.

Yes, I think so too