Skip to content

Loading…

DDC-757: Make names for tables and join columns not mandatory #5270

Closed
doctrinebot opened this Issue · 7 comments

1 participant

@doctrinebot

Jira issue originally created by user petr_motejlek:

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?

@doctrinebot

Comment created by romanb:

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

@doctrinebot

Comment created by petr_motejlek:

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.

@doctrinebot

Comment created by petr_motejlek:

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.

@doctrinebot

Comment created by petr_motejlek:

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.

@doctrinebot

Comment created by romanb:

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!

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot

Comment created by petr_motejlek:

Thank you ;)

@doctrinebot doctrinebot added this to the 2.0-BETA4 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.