Skip to content

Commit 63eddd4

Browse files
committed
coerse test to change binding syntax to @n
1 parent b5e38a1 commit 63eddd4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,25 @@ def test_merging_with_order_with_binds_coerced
15091509
relation = Post.all.merge(Post.order([Arel.sql("title LIKE ?"), "%suffix"]))
15101510
assert_equal ["title LIKE N'%suffix'"], relation.order_values
15111511
end
1512+
1513+
# Same as original but change first regexp to match sp_executesql binding syntax
1514+
coerce_tests! :test_merge_doesnt_duplicate_same_clauses
1515+
def test_merge_doesnt_duplicate_same_clauses_coerced
1516+
david, mary, bob = authors(:david, :mary, :bob)
1517+
1518+
non_mary_and_bob = Author.where.not(id: [mary, bob])
1519+
1520+
author_id = Author.connection.quote_table_name("authors.id")
1521+
assert_sql(/WHERE #{Regexp.escape(author_id)} NOT IN \((@\d), \g<1>\)'/) do
1522+
assert_equal [david], non_mary_and_bob.merge(non_mary_and_bob)
1523+
end
1524+
1525+
only_david = Author.where("#{author_id} IN (?)", david)
1526+
1527+
assert_sql(/WHERE \(#{Regexp.escape(author_id)} IN \(1\)\)\z/) do
1528+
assert_equal [david], only_david.merge(only_david)
1529+
end
1530+
end
15121531
end
15131532

15141533
module ActiveRecord

0 commit comments

Comments
 (0)