Skip to content

Commit 4d4fa8d

Browse files
mgrunbergLavika
authored andcommitted
coerse test to change binding syntax to @n (rails-sqlserver#908)
1 parent b8aae08 commit 4d4fa8d

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
@@ -1518,6 +1518,25 @@ def test_merging_with_order_with_binds_coerced
15181518
relation = Post.all.merge(Post.order([Arel.sql("title LIKE ?"), "%suffix"]))
15191519
assert_equal ["title LIKE N'%suffix'"], relation.order_values
15201520
end
1521+
1522+
# Same as original but change first regexp to match sp_executesql binding syntax
1523+
coerce_tests! :test_merge_doesnt_duplicate_same_clauses
1524+
def test_merge_doesnt_duplicate_same_clauses_coerced
1525+
david, mary, bob = authors(:david, :mary, :bob)
1526+
1527+
non_mary_and_bob = Author.where.not(id: [mary, bob])
1528+
1529+
author_id = Author.connection.quote_table_name("authors.id")
1530+
assert_sql(/WHERE #{Regexp.escape(author_id)} NOT IN \((@\d), \g<1>\)'/) do
1531+
assert_equal [david], non_mary_and_bob.merge(non_mary_and_bob)
1532+
end
1533+
1534+
only_david = Author.where("#{author_id} IN (?)", david)
1535+
1536+
assert_sql(/WHERE \(#{Regexp.escape(author_id)} IN \(1\)\)\z/) do
1537+
assert_equal [david], only_david.merge(only_david)
1538+
end
1539+
end
15211540
end
15221541

15231542
module ActiveRecord

0 commit comments

Comments
 (0)