Regex escape the table columns in query

This commit is contained in:
Aidan Haran 2023-09-21 11:14:41 +01:00
parent d56db8ff17
commit e985cb2a75

@ -1697,11 +1697,10 @@ def test_preloading_has_many_through_with_custom_scope
assert_equal 3, comments_collection.size
end.last
if current_adapter?(:Mysql2Adapter, :TrilogyAdapter)
assert_match(/WHERE `sharded_comments`.`blog_id` IN \(.+\) AND `sharded_comments`.`blog_post_id` IN \(.+\)/, sql)
else
assert_match(/WHERE "sharded_comments"."blog_id" IN \(.+\) AND "sharded_comments"."blog_post_id" IN \(.+\)/, sql)
end
c = Sharded::BlogPost.connection
quoted_blog_id = Regexp.escape(c.quote_table_name("sharded_comments.blog_id"))
quoted_blog_post_id = Regexp.escape(c.quote_table_name("sharded_comments.blog_post_id"))
assert_match(/WHERE #{quoted_blog_id} IN \(.+\) AND #{quoted_blog_post_id} IN \(.+\)/, sql)
end
test "preloading has_many association associated by a composite query_constraints" do