Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-680

[GH-428] [DBAL-563] Add interface for sequence emulated identity platforms

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

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

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

      Message:

      Currently identity columns on Oracle are implemented with a [trigger and sequence workaround](https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/OraclePlatform.php#L431) to be compatible with IDENTITY generator strategy in ORM. However, using this strategy, the last insert ID is never returned when persisting, as the sequence name generated by DBAL [is not passed to the ID-Generator instance in ORM](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L450) and thus [not passed to the driver](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Id/IdentityGenerator.php#L55) when calling `IdentityGenerator::generate()`. Therefore the Oracle driver always returns null in this case. This makes this strategy unusable.
      A similar case is given in PostgreSQL where `SERIAL` identity columns need a sequence in order to work. There is a [hackish implementation](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L453) available in ORM for this case which makes it work.
      It is possible that other vendors (when implemented) encounter the same issue. For this reason I tried to create a general solution with this PR.
      ORM needs to know which platforms do not have native support for identity columns but can emulate them with sequences. To prepare this I added an interface that identifies a platform being able to do so. Platforms implementing this interface have to return the name of the sequence used for an identity column in a table. ORM can later make use of this and pass it to the `IdentityGenerator` so that the underlying driver in return is able to supply the last insert ID.
      Current implementing platforms are PostgreSQL and Oracle.

        Activity

        Hide
        Doctrine Bot added a comment -

        A related Github Pull-Request [GH-428] was closed:
        https://github.com/doctrine/dbal/pull/428

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-428] was closed: https://github.com/doctrine/dbal/pull/428

          People

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

            Dates

            • Created:
              Updated:
              Resolved: