Skip to content

Add affected_rows to ActiveRecord::Result #1336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
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 @@ -30,12 +30,11 @@ def perform_query(raw_connection, sql, binds, type_casted_binds, prepare:, notif
result
end

def cast_result(raw_result)
if raw_result.columns.empty?
ActiveRecord::Result.empty
else
ActiveRecord::Result.new(raw_result.columns, raw_result.rows)
end
# Method `perform_query` already returns an `ActiveRecord::Result` so we have nothing to cast here. This is
# different to the MySQL/PostgreSQL adapters where the raw result is converted to `ActiveRecord::Result` in
# `cast_result`.
def cast_result(result)
result
end

# Returns the affected rows from results.
Expand Down Expand Up @@ -521,7 +520,7 @@ def handle_to_names_and_values(handle, options = {})
columns = columns.last if columns.any? && columns.all? { |e| e.is_a?(Array) } # If query returns multiple result sets, only return the columns of the last one.
columns = columns.map(&:downcase) if lowercase_schema_reflection

ActiveRecord::Result.new(columns, results)
ActiveRecord::Result.new(columns, results, affected_rows: handle.affected_rows)
else
results
end
Expand Down