Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-852

An easy way of generally setting the default id name/foreign key name suffix doctrine uses

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA4
    • Fix Version/s: 2.3
    • Component/s: Mapping Drivers
    • Security Level: All
    • Labels:
      None

      Description

      Doctrine 2 is currently using "id" as the default name for identifier columns, and "_id" as suffix for corresponding foreign key columns. I think this is quite reasonable in most cases.

      Now, assuming that for any reason I wanted to change this to something else for all relationships, currently there does not seem to be any easy way to do it.
      You will have to give a complete JoinColumn definition on every single relationship declaration, like (assuming that I want the new ID name to be "dbID"):

      /**

      • @ManyToOne(targetEntity="persistentData\model\import\Whatever", inversedBy="someReferenceThatPointsHere")
      • @JoinColumn(name="whatever_dbid", referencedColumnName="dbId")
        */

      The reason why I am doing this is that I am doing a 1:1 data import based on a data model that is already defined, and it just happens to contain properties named "id",
      which unfortunately even have a problem-domain meaning. So instead of mapping those problem-domain properties to something else (breaking my 1:1 convention), or
      using something that does have a problem-domain-meaning as a primary key (which I consider bad practice), I thought I might just use purely technical ids and instruct
      doctrine to choose a different name for those. This is, fortunately, possible. But unless I am missing something here, it needs to be specified on every single relationship.

      It would be great to have a less redundant way of configuring Doctrine to use a different name/suffix generally, e.g. by calling a setter method on the configuration object, like
      $configuration->setDefaultIdColumnName().

        Activity

        Daniel Alvarez Arribas created issue -
        Hide
        Marc Hodgins added a comment -

        Related to DDC-559

        Show
        Marc Hodgins added a comment - Related to DDC-559
        Fabio B. Silva made changes -
        Field Original Value New Value
        Assignee Roman S. Borschel [ romanb ] Fabio B. Silva [ fabio.bat.silva ]
        Hide
        Benjamin Eberlei added a comment -

        Related Pull Request was closed: https://github.com/doctrine/doctrine2/pull/241

        Show
        Benjamin Eberlei added a comment - Related Pull Request was closed: https://github.com/doctrine/doctrine2/pull/241
        Show
        Guilherme Blanco added a comment - FIxed in https://github.com/doctrine/doctrine2/commit/abb258c951dd416fc5325ef548d15c7acd35703e
        Guilherme Blanco made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.3 [ 10185 ]
        Resolution Fixed [ 1 ]
        Hide
        Benjamin Eberlei added a comment -

        A related Github Pull-Request [GH-391] was opened
        https://github.com/doctrine/doctrine2/pull/391

        Show
        Benjamin Eberlei added a comment - A related Github Pull-Request [GH-391] was opened https://github.com/doctrine/doctrine2/pull/391
        Benjamin Eberlei made changes -
        Workflow jira [ 12050 ] jira-feedback [ 14620 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14620 ] jira-feedback2 [ 16484 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 16484 ] jira-feedback3 [ 18737 ]
        Hide
        Doctrine Bot added a comment -

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

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

        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-852, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Fabio B. Silva
            Reporter:
            Daniel Alvarez Arribas
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: