Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-757

Make names for tables and join columns not mandatory

    Details

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

      Description

      Why is it necessary to specify a name when using the @Table annotation (I guess it's the same using Yaml or XML) when I just want to add some indexes or unique constraints? When I do not specify the @Table at all, the name is generated from the entity's class, why can't it be also generated when I just want to add indexes or uniqueConstraints? My point is why should I write so many same stuff so many times, when Doctrine can already use it's API to do it for me. Preferably I would like to only specify the name when I need to change it from the default, not every time I need to add some explicit indexes The same applies to the @JoinColumn annotation. When I want a nullable=false column, I have (again) specify a name for it, but the generated name would work just fine. Why do I have to specify it by hand?

        Activity

        Hide
        Roman S. Borschel added a comment -

        Yes, the default/inferred value handling is not very smart yet. We will look into improving this in the future.

        Show
        Roman S. Borschel added a comment - Yes, the default/inferred value handling is not very smart yet. We will look into improving this in the future.
        Hide
        Petr Motejlek added a comment -

        Thanks. If you'd like, I can try to look into it and make some patchsets, since I'll probably want to correct it for myself as soon as possible.

        Show
        Petr Motejlek added a comment - Thanks. If you'd like, I can try to look into it and make some patchsets, since I'll probably want to correct it for myself as soon as possible.
        Hide
        Petr Motejlek added a comment -

        I've successfully created a patch for this issue, it's at http://github.com/petr-motejlek/doctrine2/commit/d8359646fb43b7e1c42c3296ea8d7ebf3d18c51d
        I've also issued a pull request for that.

        Show
        Petr Motejlek added a comment - I've successfully created a patch for this issue, it's at http://github.com/petr-motejlek/doctrine2/commit/d8359646fb43b7e1c42c3296ea8d7ebf3d18c51d I've also issued a pull request for that.
        Hide
        Petr Motejlek added a comment -

        So the above-mentioned fix was not that good as I thought it was. This one works perfectly http://github.com/petr-motejlek/doctrine2/commit/e2522a9d4ed74c12356000d03a0aad7c6a34841f#diff-1. Now it should be possible to omit the JoinTable, Table and JoinColumn names, Doctrine will try to generate them automatically.

        Show
        Petr Motejlek added a comment - So the above-mentioned fix was not that good as I thought it was. This one works perfectly http://github.com/petr-motejlek/doctrine2/commit/e2522a9d4ed74c12356000d03a0aad7c6a34841f#diff-1 . Now it should be possible to omit the JoinTable, Table and JoinColumn names, Doctrine will try to generate them automatically.
        Hide
        Roman S. Borschel added a comment -

        I committed a modified version of your patch (i.e. it also allows leaving off referencedColumnName as well). I also made inferred default column names lowercase for aesthetics.

        Thanks for your help!

        Show
        Roman S. Borschel added a comment - I committed a modified version of your patch (i.e. it also allows leaving off referencedColumnName as well). I also made inferred default column names lowercase for aesthetics. Thanks for your help!
        Hide
        Petr Motejlek added a comment -

        Thank you

        Show
        Petr Motejlek added a comment - Thank you

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Petr Motejlek
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: