Skip to content

Commit 6d2f4f5

Browse files
committed
fix: fixed missing mark_transaction_written_if_write and in_transaction? methods
1 parent bed24fd commit 6d2f4f5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

lib/active_record/connection_adapters/redshift_8_0_adapter.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@ class RedshiftAdapter < AbstractAdapter
9090
include Redshift::SchemaStatements
9191
include Redshift::DatabaseStatements
9292

93+
# Rails 8.1+ compatibility: mark_transaction_written_if_write was removed
94+
# and replaced with mark_transaction_written (no parameters).
95+
# This method provides backward compatibility for our adapter.
96+
if ActiveRecord.version >= Gem::Version.new('8.1.0')
97+
def mark_transaction_written_if_write(sql) # :nodoc:
98+
transaction = current_transaction
99+
if transaction.open? && write_query?(sql)
100+
mark_transaction_written
101+
end
102+
end
103+
end
104+
105+
# Compatibility: in_transaction? is defined in PostgreSQLAdapter but not in AbstractAdapter.
106+
# Since RedshiftAdapter inherits from AbstractAdapter (not PostgreSQLAdapter),
107+
# we need to provide this method. It's used for prepared statement cache handling.
108+
def in_transaction? # :nodoc:
109+
open_transactions > 0
110+
end
111+
93112
def schema_creation # :nodoc:
94113
Redshift::SchemaCreation.new self
95114
end

0 commit comments

Comments
 (0)