1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/cases/relation
Ryuta Kamizono 7219eb2cd2 Support relation.and for intersection as Set theory
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.
2020-06-07 11:25:51 +09:00
..
delegation_test.rb Dogfooding "active_support/core_ext/symbol/starts_ends_with" 2020-05-06 14:19:25 +09:00
delete_all_test.rb Revert unused code and re-using query annotation for update_all and delete_all 2019-04-01 15:04:11 +09:00
merging_test.rb Support relation.and for intersection as Set theory 2020-06-07 11:25:51 +09:00
mutation_test.rb Add strict_loading mode to prevent lazy loading 2020-02-20 08:32:48 -05:00
or_test.rb Allow relations with different SQL comments in or 2020-05-24 22:43:10 +09:00
predicate_builder_test.rb reset_column_information does not reset @predicate_builder 2020-02-25 13:48:19 +09:00
record_fetch_warning_test.rb
select_test.rb Retain selections with includes and joins 2019-12-03 20:45:12 -05:00
update_all_test.rb touch_attributes_with_time takes keyword arguments 2020-04-17 18:55:58 +09:00
where_chain_test.rb Fix rewhere to truly overwrite collided where clause by new where clause 2020-05-05 11:45:29 +09:00
where_clause_test.rb Refactor invert predicate 2020-03-04 09:28:51 -05:00
where_test.rb Allow where with through association to be expanded condition 2020-05-29 13:22:07 +09:00