Skip to content

Commit bb4cc27

Browse files
authored
Merge pull request rails#47670 from john-h-k/add-relation-intersect
Add `intersects?` to `Relation`
2 parents eac3208 + c837ae6 commit bb4cc27

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

activerecord/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
* Add support for `Array#intersect?` to `ActiveRecord::Relation`.
2+
3+
`Array#intersect?` is only available on Ruby 3.1 or later.
4+
5+
This allows the Rubocop `Style/ArrayIntersect` cop to work with `ActiveRecord::Relation` objects.
6+
7+
*John Harry Kelly*
8+
19
* The deferrable foreign key can be passed to `t.references`.
210

311
*Hiroyuki Ishii*

activerecord/lib/active_record/relation/delegation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def #{method}(...)
9797
# may vary depending on the klass of a relation, so we create a subclass of Relation
9898
# for each different klass, and the delegations are compiled into that subclass only.
9999

100-
delegate :to_xml, :encode_with, :length, :each, :join,
100+
delegate :to_xml, :encode_with, :length, :each, :join, :intersects?,
101101
:[], :&, :|, :+, :-, :sample, :reverse, :rotate, :compact, :in_groups, :in_groups_of,
102102
:to_sentence, :to_fs, :to_formatted_s, :as_json,
103103
:shuffle, :split, :slice, :index, :rindex, to: :records

activerecord/test/cases/relation/delegation_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
module ActiveRecord
1010
module DelegationTests
1111
ARRAY_DELEGATES = [
12-
:+, :-, :|, :&, :[], :shuffle,
12+
:+, :-, :|, :&, :[], :shuffle, :intersects?,
1313
:all?, :collect, :compact, :detect, :each, :each_cons, :each_with_index,
1414
:exclude?, :find_all, :flat_map, :group_by, :include?, :length,
1515
:map, :none?, :one?, :partition, :reject, :reverse, :rotate,

0 commit comments

Comments
 (0)