Skip to content

Commit 6dfe92b

Browse files
committed
Pass connection_pool to more database-related exceptions raisings
1 parent 057563a commit 6dfe92b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def exec_cache(sql, name, binds, async:, allow_retry:, materialize_transactions:
912912
# Nothing we can do if we are in a transaction because all commands
913913
# will raise InFailedSQLTransaction
914914
if in_transaction?
915-
raise ActiveRecord::PreparedStatementCacheExpired.new(e.cause.message)
915+
raise ActiveRecord::PreparedStatementCacheExpired.new(e.cause.message, connection_pool: @pool)
916916
else
917917
@lock.synchronize do
918918
# outside of transactions we can simply flush this query and retry

activerecord/lib/active_record/connection_adapters/schema_cache.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def data_sources(_connection, name) # :nodoc:
354354
# Get the columns for a table
355355
def columns(pool, table_name)
356356
if ignored_table?(table_name)
357-
raise ActiveRecord::StatementInvalid, "Table '#{table_name}' doesn't exist"
357+
raise ActiveRecord::StatementInvalid.new("Table '#{table_name}' doesn't exist", connection_pool: pool)
358358
end
359359

360360
@columns.fetch(table_name) do

activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def check_all_foreign_keys_valid! # :nodoc:
263263

264264
unless result.blank?
265265
tables = result.map { |row| row["table"] }
266-
raise ActiveRecord::StatementInvalid.new("Foreign key violations found: #{tables.join(", ")}", sql: sql)
266+
raise ActiveRecord::StatementInvalid.new("Foreign key violations found: #{tables.join(", ")}", sql: sql, connection_pool: @pool)
267267
end
268268
end
269269

@@ -481,7 +481,7 @@ def table_structure(table_name)
481481
else
482482
internal_exec_query("PRAGMA table_info(#{quote_table_name(table_name)})", "SCHEMA")
483483
end
484-
raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty?
484+
raise ActiveRecord::StatementInvalid.new("Could not find table '#{table_name}'", connection_pool: @pool) if structure.empty?
485485
table_structure_with_collation(table_name, structure)
486486
end
487487
alias column_definitions table_structure

0 commit comments

Comments
 (0)