aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-13 02:06:06 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-13 02:47:46 +0900
commit0ee96d13de29680e148ccb8e5b68025f29fd091c (patch)
treee8e2095bc74f34b8a0447cace738368e8ff79bef /activerecord/test/cases/calculations_test.rb
parented9acb4fcc793ce1ab68a0e5076dc9458cc7f218 (diff)
downloadrails-0ee96d13de29680e148ccb8e5b68025f29fd091c.tar.gz
rails-0ee96d13de29680e148ccb8e5b68025f29fd091c.tar.bz2
rails-0ee96d13de29680e148ccb8e5b68025f29fd091c.zip
Fix `pluck` and `select` with custom attributes
Currently custom attributes are always qualified by the table name in the generated SQL wrongly even if the table doesn't have the named column, it would cause an invalid SQL error. Custom attributes should only be qualified if the table has the same named column.
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 850bc49676..b001667ac9 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -690,8 +690,9 @@ class CalculationsTest < ActiveRecord::TestCase
end
def test_pluck_not_auto_table_name_prefix_if_column_joined
- Company.create!(name: "test", contracts: [Contract.new(developer_id: 7)])
- assert_equal [7], Company.joins(:contracts).pluck(:developer_id)
+ company = Company.create!(name: "test", contracts: [Contract.new(developer_id: 7)])
+ metadata = company.contracts.first.metadata
+ assert_equal [metadata], Company.joins(:contracts).pluck(:metadata)
end
def test_pluck_with_selection_clause