Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 98d48fc

Browse files
committedMay 15, 2024·
Fix for text showplan
1 parent 26b81cf commit 98d48fc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎lib/active_record/connection_adapters/sqlserver/database_statements.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,11 @@ def handle_to_names_and_values(handle, options = {})
432432
qo[:as] = (options[:ar_result] || options[:fetch] == :rows) ? :array : :hash
433433
end
434434
results = handle.each(query_options)
435-
columns = lowercase_schema_reflection ? handle.fields.map { |c| c.downcase } : handle.fields
435+
436+
columns = handle.fields
437+
# If query returns multiple result sets, only return the columns of the last one.
438+
columns = columns.last if columns.all? { |e| e.is_a?(Array) }
439+
columns = columns.map(&:downcase) if lowercase_schema_reflection
436440

437441
options[:ar_result] ? ActiveRecord::Result.new(columns, results) : results
438442
end

0 commit comments

Comments
 (0)