aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authororekyuu <orekyuu@pixiv.com>2018-01-26 10:29:41 +0900
committerorekyuu <orekyuu@pixiv.com>2018-01-26 10:29:41 +0900
commitc9822ace4c8961336527670e7eef59093f515dfd (patch)
treef7b1f56ae2fb5013fa5dbcf70d0976c8fa74afad /activerecord/test
parentbbed4c32e469ee74718d5a9cc52792cb473700b9 (diff)
downloadrails-c9822ace4c8961336527670e7eef59093f515dfd.tar.gz
rails-c9822ace4c8961336527670e7eef59093f515dfd.tar.bz2
rails-c9822ace4c8961336527670e7eef59093f515dfd.zip
Fix not expanded problem when passing an Array object as argument to the where method using composed_of column.
Fixes #31723 ``` david_balance = customers(:david).balance Customer.where(balance: [david_balance]).to_sql # Before: WHERE `customers`.`balance` = NULL # After : WHERE `customers`.`balance` = 50 ```
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/finder_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 4769ffd64d..ebbd2b8118 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -868,6 +868,25 @@ class FinderTest < ActiveRecord::TestCase
assert_equal customers(:david), found_customer
end
+ def test_hash_condition_find_with_aggregate_having_three_mapping_array
+ david_address = customers(:david).address
+ zaphod_address = customers(:zaphod).address
+ assert_kind_of Address, david_address
+ assert_kind_of Address, zaphod_address
+ assert_raise(NoMethodError) do
+ Customer.where(address: [david_address, zaphod_address])
+ end
+ end
+
+ def test_hash_condition_find_with_aggregate_having_one_mapping_array
+ david_balance = customers(:david).balance
+ zaphod_balance = customers(:zaphod).balance
+ assert_kind_of Money, david_balance
+ assert_kind_of Money, zaphod_balance
+ found_customers = Customer.where(balance: [david_balance, zaphod_balance])
+ assert_equal [customers(:david), customers(:zaphod)], found_customers
+ end
+
def test_hash_condition_find_with_aggregate_attribute_having_same_name_as_field_and_key_value_being_aggregate
gps_location = customers(:david).gps_location
assert_kind_of GpsLocation, gps_location