Skip to content

Commit

Permalink
Ensure we're clearing statement cache on same connection
Browse files Browse the repository at this point in the history
  • Loading branch information
janko committed Oct 16, 2024
1 parent 30b5375 commit 15e1699
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/sequel/extensions/activerecord_connection/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ def transaction(opts = OPTS)
fail Error, "#{key.inspect} transaction option is currently not supported" if opts.key?(key)
end

super
rescue => e
with_activerecord_connection(&:clear_cache!) if e.class.name == "ActiveRecord::PreparedStatementCacheExpired" && !in_transaction?
raise
super do |conn|
yield conn
rescue => e
activerecord_connection.clear_cache! if e.class.name == "ActiveRecord::PreparedStatementCacheExpired"
raise
end
end

private
Expand Down

0 comments on commit 15e1699

Please sign in to comment.