aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-06-10 06:21:23 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-06-10 06:21:23 +0900
commit6607ecb2a1ccc9b43cfb8db2d06dc5301a5320ba (patch)
treec44a96d57dd48f62b994a239cc815903a4a5ff8a /activerecord/test/cases
parent1340498d2102423665cc5cfe7be7cdba32c72928 (diff)
downloadrails-6607ecb2a1ccc9b43cfb8db2d06dc5301a5320ba.tar.gz
rails-6607ecb2a1ccc9b43cfb8db2d06dc5301a5320ba.tar.bz2
rails-6607ecb2a1ccc9b43cfb8db2d06dc5301a5320ba.zip
Allow `column_name AS alias` as safe SQL string
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/unsafe_raw_sql_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/unsafe_raw_sql_test.rb b/activerecord/test/cases/unsafe_raw_sql_test.rb
index fc92bf73c9..d4cb51afba 100644
--- a/activerecord/test/cases/unsafe_raw_sql_test.rb
+++ b/activerecord/test/cases/unsafe_raw_sql_test.rb
@@ -223,6 +223,16 @@ class UnsafeRawSqlTest < ActiveRecord::TestCase
assert_equal titles_expected, titles_disabled
end
+ test "pluck: allows string column name with alias" do
+ titles_expected = Post.pluck(Arel.sql("title"))
+
+ titles_depr = with_unsafe_raw_sql_deprecated { Post.pluck("title AS posts_title") }
+ titles_disabled = with_unsafe_raw_sql_disabled { Post.pluck("title AS posts_title") }
+
+ assert_equal titles_expected, titles_depr
+ assert_equal titles_expected, titles_disabled
+ end
+
test "pluck: allows symbol column name" do
titles_expected = Post.pluck(Arel.sql("title"))