Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2020

[GH-440] The schema tool now doesn't add a foreign constraint when subclassess of...

    Details

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

      Description

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

      Url: https://github.com/doctrine/doctrine2/pull/440

      Message:

      ... a STI use the same field to map relations with entities of different classes

      It seems that there are no particular side-effects in mapping different relationship using the same table column name in different subclasses of a STI hierarchy.
      Eg. Tag superclass of BookTag (id, object_id, comment) and MovieTag (id, object_id, comment), so having two attributes $book and $movie mapped to the same object_id field with @JoinColumn annotation

      I wasn't sure about this so I tested to see if there were errors. And I was surprised that everything runs without any particular problem.
      Moreover this is a really interesting (wanted? unwanted?) feature, very useful if you have huge tables that need to be joined with other table using the discriminator and object_id columns, or if you have some kind of logging class and you need to keep the table efficient and small. The only problem is that the schema generator always inserts a foreign column constraint (probably the last specified) when generating these kind of Entities.

      This PR ensures that the foreign key is not added if there are at least two different classes mapped on the same field of a db table.

        Activity

        Benjamin Eberlei created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.4 [ 10321 ]
        Resolution Fixed [ 1 ]
        Hide
        Doctrine Bot added a comment -

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

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

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2020, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Benjamin Eberlei
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: