From 990af3d203fd573e55140a84fc48ee1a06db5587 Mon Sep 17 00:00:00 2001 From: Matias Grunberg Date: Mon, 3 Jan 2022 10:17:21 -0300 Subject: [PATCH] Remove requirement that query ends with comments For the SQL Server adapter (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/) the tests in QueryLogsTest need to be coerced and re-implemented (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/972) because the tests are expecting the SQL to end with the comment but the SQL generated by the SQL Server adapter ends with prepare statement bindings. This PR just removes the end of string check in the regular expressions. These changes do not affect the purpose of the tests and removes the need coerce & re-implement the same tests in the SQL Server adapter. --- activerecord/test/cases/query_logs_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/activerecord/test/cases/query_logs_test.rb b/activerecord/test/cases/query_logs_test.rb index 05207f17e3..3353a722a9 100644 --- a/activerecord/test/cases/query_logs_test.rb +++ b/activerecord/test/cases/query_logs_test.rb @@ -151,7 +151,7 @@ class QueryLogsTest < ActiveRecord::TestCase def test_custom_basic_tags ActiveRecord::QueryLogs.tags = [ :application, { custom_string: "test content" } ] - assert_sql(%r{/\*application:active_record,custom_string:test content\*/$}) do + assert_sql(%r{/\*application:active_record,custom_string:test content\*/}) do Dashboard.first end end @@ -159,7 +159,7 @@ class QueryLogsTest < ActiveRecord::TestCase def test_custom_proc_tags ActiveRecord::QueryLogs.tags = [ :application, { custom_proc: -> { "test content" } } ] - assert_sql(%r{/\*application:active_record,custom_proc:test content\*/$}) do + assert_sql(%r{/\*application:active_record,custom_proc:test content\*/}) do Dashboard.first end end @@ -170,7 +170,7 @@ class QueryLogsTest < ActiveRecord::TestCase { custom_proc: -> { "test content" }, another_proc: -> { "more test content" } }, ] - assert_sql(%r{/\*application:active_record,custom_proc:test content,another_proc:more test content\*/$}) do + assert_sql(%r{/\*application:active_record,custom_proc:test content,another_proc:more test content\*/}) do Dashboard.first end end @@ -179,7 +179,7 @@ class QueryLogsTest < ActiveRecord::TestCase ActiveSupport::ExecutionContext[:foo] = "bar" ActiveRecord::QueryLogs.tags = [ :application, { custom_context_proc: ->(context) { context[:foo] } } ] - assert_sql(%r{/\*application:active_record,custom_context_proc:bar\*/$}) do + assert_sql(%r{/\*application:active_record,custom_context_proc:bar\*/}) do Dashboard.first end end