DDC-559: Allow table name and column names to be modified by a user-supplied inflector #5067

Closed
doctrinebot opened this Issue Apr 29, 2010 · 7 comments

1 participant

@doctrinebot

Jira issue originally created by user mjh_ca:

With the annotation mapping driver, table names default to the same as the class name, and table columns default to the same name as the field (class property) name.

/*** @Entity **/
class MyEntity // db table will by default be "MyEntity"
{
    // ...

    /****
     * @Column(type="string")
     */
    protected $myProperty; // defaults to table column "myProperty" 
}

It would be great if we could override this behavior by passing in a custom inflector. So for example you could default all camelCase fields to be underscore_separated as column names in the database without needing to manually specify this in the annotations.

@doctrinebot

Comment created by romanb:

I think Hibernate, for example, has naming strategies for this and you can implement your own custom NamingStrategy that implements a specific (default) naming convention. Maybe we want a similar approach.

@doctrinebot

Comment created by shurakai:

Whats a use case for this? One could use individual table / column names via hardcoding. (@table, i guess. see manual) Is this unwanted?

@doctrinebot

Comment created by mjh_ca:

Sure there is a use case. With a large schema, hardcoding via individual @table and @column annotations is error-prone. A global "default" inflector (or naming strategy, as Roman suggests) would much cleaner. Allowing customization of "defaults" doesn't seem unreasonable to me.

@doctrinebot

Comment created by @beberlei:

This issue is referenced in Github Pull-Request GH-241
#241

@doctrinebot

Comment created by @beberlei:

Related Pull Request was closed: #241

@doctrinebot

Comment created by @guilhermeblanco:

Fixed in abb258c

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment