Skip to content

Connections don't have references to their open transactions #158

@matthewmcgarvey

Description

@matthewmcgarvey

Right now if you want to use a transaction, you have to hold onto a reference to it. In Avram, I'm working on adding the ability to run specs in a transaction that is rolled back instead of truncating the database for a major speed improvement. To do that, I monkey patched onto DB::Connection a list of transactions that functions as a stack where the first item in the list would be the parent transaction and any transactions after that would be children. I think this would be a useful thing to have in the actual library.

Reference: luckyframework/avram#780

Inspiration is from Rails: https://github.com/rails/rails/blob/619e523613e942d3fd16b43fc60be9060a29622d/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb#L226

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions