Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-947

[GH-634] Transaction object definition

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      This issue is created automatically through a Github pull request on behalf of BenMorel:

      Url: https://github.com/doctrine/dbal/pull/634

      Message:

      To move forward with the Transaction Object, here is an alternative proposal to #571.

      This keeps the same basic idea, but now `createTransaction()` returns a `TransactionDefinition` object, which is configurable, and has a `begin()` method that starts the underlying transaction and returns the `Transaction` object:

      $tx = $em->createTransaction() // TransactionDefinition
      ->withIsolationLevel(Connection::TRANSACTION_SERIALIZABLE) // TransactionDefinition
      ->begin(); // Transaction

      I think that this implementation checks all the boxes:

      • Clear separation between the Transaction and its Definition
      • Once the Transaction is created, its Definition is set and cannot be changed
      • No risk to forget to call `begin()`: if you do, you'll deal with a TransactionDefinition and just get a call to undefined method if you try to `commit()` it. Plus, your IDE will be able to warn you while coding.

      And needless to say, we're still keeping 100% BC compatibility.

      What do you think?

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Doctrine Bot
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: