File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
lib/active_record/relation/predicate_builder Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ def polymorphic_clause?
59
59
def convert_to_id ( value )
60
60
if primary_key . is_a? ( Array )
61
61
primary_key . map do |attribute |
62
+ next nil if value . nil?
63
+
62
64
if attribute == "id"
63
65
value . id_value
64
66
else
Original file line number Diff line number Diff line change @@ -149,6 +149,15 @@ def test_with_tuple_syntax_and_large_values_list
149
149
end
150
150
end
151
151
152
+ def test_where_with_nil_cpk_association
153
+ order = Cpk ::Order . create! ( id : [ 1 , 2 ] )
154
+ book = order . books . create! ( id : [ 3 , 4 ] )
155
+ assert_includes Cpk ::Book . where ( order : order ) , book
156
+
157
+ book . update! ( order : nil )
158
+ assert_includes Cpk ::Book . where ( order : nil ) , book
159
+ end
160
+
152
161
def test_belongs_to_shallow_where
153
162
author = Author . new
154
163
author . id = 1
You can’t perform that action at this time.
0 commit comments