diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-09-21 11:14:32 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-09-21 11:14:32 -0600 |
commit | 9cc324a3f1348430e5b6db58bbddab5090c708c8 (patch) | |
tree | d53057f5003153206a383b984f5631c5a23c1c9b /activerecord/test/cases | |
parent | dac7d0d046bb07a061cbaf6bb526ff96bf73bc1d (diff) | |
download | rails-9cc324a3f1348430e5b6db58bbddab5090c708c8.tar.gz rails-9cc324a3f1348430e5b6db58bbddab5090c708c8.tar.bz2 rails-9cc324a3f1348430e5b6db58bbddab5090c708c8.zip |
Ensure aliased attributes passed to `select` are quoted if using `from`
Fixes #21488
[Sean Griffin & johanlunds]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 8256762f96..5aa0ea85a5 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1897,4 +1897,14 @@ class RelationTest < ActiveRecord::TestCase def test_relation_join_method assert_equal 'Thank you for the welcome,Thank you again for the welcome', Post.first.comments.join(",") end + + def test_selecting_aliased_attribute_quotes_column_name_when_from_is_used + klass = Class.new(ActiveRecord::Base) do + self.table_name = :test_with_keyword_column_name + alias_attribute :description, :desc + end + klass.create!(description: "foo") + + assert_equal ["foo"], klass.select(:description).from(klass.all).map(&:desc) + end end |