mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
7219eb2cd2
As described at #39328, `relation.merge` behaves inspired as Hash-like merge for where clause. In other words, currently there is no official way to intersect the result by both relation conditions (i.e. there is no official way to maintain both relation conditions). To resolve that issue, I'd like to support a way to intersect relations as `relation.and`. ```ruby david_and_mary = Author.where(id: [david, mary]) mary_and_bob = Author.where(id: [mary, bob]) # => [bob] david_and_mary.merge(mary_and_bob) # => [mary, bob] david_and_mary.and(mary_and_bob) # => [mary] david_and_mary.or(mary_and_bob) # => [david, mary, bob] ``` Fixes #39232. |
||
---|---|---|
.. | ||
delegation_test.rb | ||
delete_all_test.rb | ||
merging_test.rb | ||
mutation_test.rb | ||
or_test.rb | ||
predicate_builder_test.rb | ||
record_fetch_warning_test.rb | ||
select_test.rb | ||
update_all_test.rb | ||
where_chain_test.rb | ||
where_clause_test.rb | ||
where_test.rb |