提交 4a5b3ca9 编写于 作者: B Ben Toews 提交者: Matthew Draper

use database agnostic function/quoting in test

上级 8ef71ac4
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册