Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def unprepare_sqlserver_statement(sql)
executesql_args = executesql.split(', ')
found_args = executesql_args.reject! { |arg| arg =~ SQLSERVER_PARAM_MATCHER }
executesql_args.pop if found_args && executesql_args.many?
executesql = executesql_args.join(', ').strip.match(/N'(.*)'/)[1]
executesql = executesql_args.join(', ').strip.match(/N'(.*)'/m)[1]
Utils.unquote_string(executesql)
else
sql
Expand Down
6 changes: 6 additions & 0 deletions test/cases/showplan_test_sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class ShowplanTestSqlserver < ActiveRecord::TestCase
assert plan.starts_with?("EXPLAIN for: SELECT [cars].* FROM [cars] WHERE [cars].[id] = 1")
assert plan.include?("Clustered Index Seek"), 'make sure we do not showplan the sp_executesql'
end

should 'from multiline statement' do
plan = Car.where("\n id = 1 \n").explain
assert plan.starts_with?("EXPLAIN for: SELECT [cars].* FROM [cars] WHERE (\n id = 1 \n)")
assert plan.include?("Clustered Index Seek"), 'make sure we do not showplan the sp_executesql'
end

should 'from prepared statement' do
plan = capture_logger do
Expand Down