aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorBen Toews <mastahyeti@gmail.com>2017-10-26 12:00:22 -0600
committerMatthew Draper <matthew@trebex.net>2017-11-09 22:42:15 +1030
commit4a5b3ca972e867d9b9276dcd98b0a6b9b6fb7583 (patch)
treeb64479a6c712884fc7ddd7be7ef7ecdb3017b5c2 /activerecord
parent8ef71ac4a119a4c03d78db2372b41ddcc8a95035 (diff)
downloadrails-4a5b3ca972e867d9b9276dcd98b0a6b9b6fb7583.tar.gz
rails-4a5b3ca972e867d9b9276dcd98b0a6b9b6fb7583.tar.bz2
rails-4a5b3ca972e867d9b9276dcd98b0a6b9b6fb7583.zip
use database agnostic function/quoting in test
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/unsafe_raw_sql_test.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/test/cases/unsafe_raw_sql_test.rb b/activerecord/test/cases/unsafe_raw_sql_test.rb
index 861df8f1da..5809d05327 100644
--- a/activerecord/test/cases/unsafe_raw_sql_test.rb
+++ b/activerecord/test/cases/unsafe_raw_sql_test.rb
@@ -139,10 +139,10 @@ class UnsafeRawSqlTest < ActiveRecord::TestCase
end
test "order: allows Arel.sql with binds" do
- ids_expected = Post.order(Arel.sql('INSTR(title, "comments"), id')).pluck(:id)
+ ids_expected = Post.order(Arel.sql("REPLACE(title, 'misc', 'zzzz'), id")).pluck(:id)
- ids_depr = with_unsafe_raw_sql_deprecated { Post.order([Arel.sql("INSTR(title, ?), id"), "comments"]).pluck(:id) }
- ids_disabled = with_unsafe_raw_sql_disabled { Post.order([Arel.sql("INSTR(title, ?), id"), "comments"]).pluck(:id) }
+ ids_depr = with_unsafe_raw_sql_deprecated { Post.order([Arel.sql("REPLACE(title, ?, ?), id"), "misc", "zzzz"]).pluck(:id) }
+ ids_disabled = with_unsafe_raw_sql_disabled { Post.order([Arel.sql("REPLACE(title, ?, ?), id"), "misc", "zzzz"]).pluck(:id) }
assert_equal ids_expected, ids_depr
assert_equal ids_expected, ids_disabled
@@ -151,7 +151,7 @@ class UnsafeRawSqlTest < ActiveRecord::TestCase
test "order: disallows invalid bind statement" do
with_unsafe_raw_sql_disabled do
assert_raises(ActiveRecord::UnknownAttributeReference) do
- Post.order(["INSTR(title, ?), id", "comments"]).pluck(:id)
+ Post.order(["REPLACE(title, ?, ?), id", "misc", "zzzz"]).pluck(:id)
end
end
end