Skip to content

Onyx::SQL.transaction must not affect the repo #18

@vladfaust

Description

@vladfaust
2.times do
  spawn do
    Onyx::SQL.transaction do |tx|
      sleep(rand)
      Onyx::SQL.query # Which tx is it using now – the first or the second one?
    end
  end
end

Proposed API:

Onyx::SQL.transaction do |tx|
  repo = Onyx::SQL.repo.dup
  repo.db = tx # Should patch Onyx::SQL for that
  repo.query() # Instead of Onyx::SQL.query
  # The tx is commited in the end as before
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingBreaking changedesign flawWorks as expected, but overall wrong

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions