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

Closed
opened 2026-01-22 12:46:59 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 29, 2010).

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.

Originally created by @doctrinebot on GitHub (Apr 29, 2010). 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.
admin added the New Feature label 2026-01-22 12:46:59 +01:00
admin closed this issue 2026-01-22 12:47:01 +01:00
Author
Owner

@doctrinebot commented on GitHub (Apr 30, 2010):

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 commented on GitHub (Apr 30, 2010): 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.
Author
Owner

@doctrinebot commented on GitHub (May 21, 2010):

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 commented on GitHub (May 21, 2010): 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?
Author
Owner

@doctrinebot commented on GitHub (May 22, 2010):

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 commented on GitHub (May 22, 2010): 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.
Author
Owner

@doctrinebot commented on GitHub (Dec 23, 2011):

Comment created by @beberlei:

This issue is referenced in Github Pull-Request GH-241
https://github.com/doctrine/doctrine2/pull/241

@doctrinebot commented on GitHub (Dec 23, 2011): Comment created by @beberlei: This issue is referenced in Github Pull-Request GH-241 https://github.com/doctrine/doctrine2/pull/241
Author
Owner

@doctrinebot commented on GitHub (Dec 24, 2011):

Comment created by @beberlei:

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

@doctrinebot commented on GitHub (Dec 24, 2011): Comment created by @beberlei: Related Pull Request was closed: https://github.com/doctrine/doctrine2/pull/241
Author
Owner

@doctrinebot commented on GitHub (Dec 24, 2011):

Comment created by @guilhermeblanco:

Fixed in abb258c951

@doctrinebot commented on GitHub (Dec 24, 2011): Comment created by @guilhermeblanco: Fixed in https://github.com/doctrine/doctrine2/commit/abb258c951dd416fc5325ef548d15c7acd35703e
Author
Owner

@doctrinebot commented on GitHub (Dec 24, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Dec 24, 2011): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#692