Skip to content

Commit 23d1e07

Browse files
committed
Refactor Active Record Adapter#handle_warnings
It's now automatically called from AbstractAdapter.
1 parent dcbb5c2 commit 23d1e07

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,11 @@ def raw_execute(sql, name = nil, binds = [], prepare: false, async: false, allow
553553
type_casted_binds = type_casted_binds(binds)
554554
log(sql, name, binds, type_casted_binds, async: async) do |notification_payload|
555555
with_raw_connection(allow_retry: allow_retry, materialize_transactions: materialize_transactions) do |conn|
556-
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
556+
result = ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
557557
perform_query(conn, sql, binds, type_casted_binds, prepare: prepare, notification_payload: notification_payload, batch: batch)
558558
end
559+
handle_warnings(result, sql)
560+
result
559561
end
560562
end
561563
end
@@ -564,6 +566,9 @@ def perform_query(raw_connection, sql, binds, type_casted_binds, prepare:, notif
564566
raise NotImplementedError
565567
end
566568

569+
def handle_warnings(raw_result, sql)
570+
end
571+
567572
# Receive a native adapter result object and returns an ActiveRecord::Result object.
568573
def cast_result(raw_result)
569574
raise NotImplementedError

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def extended_type_map_key
759759
end
760760
end
761761

762-
def handle_warnings(sql)
762+
def handle_warnings(_initial_result, sql)
763763
return if ActiveRecord.db_warnings_action.nil? || @raw_connection.warning_count == 0
764764

765765
warning_count = @raw_connection.warning_count

activerecord/lib/active_record/connection_adapters/mysql2/database_statements.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def perform_query(raw_connection, sql, binds, type_casted_binds, prepare:, notif
9494
raw_connection.abandon_results!
9595

9696
verified!
97-
handle_warnings(sql)
9897
result
9998
ensure
10099
if reset_multi_statement && active?

activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def perform_query(raw_connection, sql, binds, type_casted_binds, prepare:, notif
163163
end
164164

165165
verified!
166-
handle_warnings(result)
167166

168167
notification_payload[:affected_rows] = result.cmd_tuples
169168
notification_payload[:row_count] = result.count
@@ -215,7 +214,7 @@ def suppress_composite_primary_key(pk)
215214
pk unless pk.is_a?(Array)
216215
end
217216

218-
def handle_warnings(sql)
217+
def handle_warnings(result, sql)
219218
@notice_receiver_sql_warnings.each do |warning|
220219
next if warning_ignored?(warning)
221220

activerecord/lib/active_record/connection_adapters/trilogy/database_statements.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def perform_query(raw_connection, sql, binds, type_casted_binds, prepare:, notif
2929
raw_connection.next_result
3030
end
3131
verified!
32-
handle_warnings(sql)
3332

3433
notification_payload[:affected_rows] = result.affected_rows
3534
notification_payload[:row_count] = result.count

0 commit comments

Comments
 (0)