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 @@ -291,9 +291,11 @@ def execute_procedure(proc_name, *variables)
end.join(", ")
sql = "EXEC #{proc_name} #{vars}".strip

result = nil
intent = QueryIntent.new(adapter: self, processed_sql: sql)

log(intent, "Execute Procedure") do |notification_payload|
start_intent_log(intent)
begin
with_raw_connection do |conn|
result = internal_raw_execute(intent.processed_sql, conn)
verified!
Expand All @@ -305,9 +307,15 @@ def execute_procedure(proc_name, *variables)
end

result = result.each.map { |row| row.is_a?(Hash) ? row.with_indifferent_access : row }
notification_payload[:row_count] = result.count
result
intent.notification_payload[:row_count] = result.count
end

finish_intent_log(intent)
result
rescue => error
error.set_query(intent.processed_sql, intent.binds) if error.is_a?(StatementInvalid)
finish_intent_log(intent, exception: error)
raise
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def test_belongs_to_with_primary_key_joins_on_correct_column_coerced
def test_belongs_to_coerced
client = Client.find(3)
first_firm = companies(:first_firm)
assert_queries_and_values_match(/FETCH NEXT @3 ROWS ONLY/, ["Firm", "Agency", 1, 1]) do
assert_queries_and_values_match(/FETCH NEXT @. ROWS ONLY/, ["Firm", "Agency", 1, 1]) do
assert_equal first_firm, client.firm
assert_equal first_firm.name, client.firm.name
end
Expand Down
Loading