File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
lib/active_record/relation Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,10 @@ def not(opts, *rest)
64
64
65
65
private
66
66
def not_behaves_as_nor? ( opts )
67
- opts . is_a? ( Hash ) && opts . size > 1
67
+ return false unless opts . is_a? ( Hash )
68
+
69
+ opts . any? { |k , v | v . is_a? ( Hash ) && v . size > 1 } ||
70
+ opts . size > 1
68
71
end
69
72
end
70
73
Original file line number Diff line number Diff line change @@ -181,6 +181,18 @@ def test_where_not_polymorphic_id_and_type_as_nor_is_deprecated
181
181
assert_equal all - expected , only . sort_by ( &:id ) . map ( &:estimate_of )
182
182
end
183
183
184
+ def test_where_not_association_as_nor_is_deprecated
185
+ treasure = Treasure . create! ( name : "my_treasure" )
186
+ PriceEstimate . create! ( estimate_of : treasure , price : 2 , currency : "USD" )
187
+ PriceEstimate . create ( estimate_of : treasure , price : 2 , currency : "EUR" )
188
+
189
+ assert_deprecated do
190
+ result = Treasure . joins ( :price_estimates ) . where . not ( price_estimates : { price : 2 , currency : "USD" } )
191
+
192
+ assert_predicate result , :empty?
193
+ end
194
+ end
195
+
184
196
def test_polymorphic_nested_array_where
185
197
treasure = Treasure . new
186
198
treasure . id = 1
Original file line number Diff line number Diff line change 746
746
t . string :estimate_of_type
747
747
t . integer :estimate_of_id
748
748
t . integer :price
749
+ t . string :currency
749
750
end
750
751
751
752
create_table :products , force : true do |t |
You can’t perform that action at this time.
0 commit comments