Database columns that start with a number create invalid entities #5461

Closed
opened 2026-01-22 15:08:16 +01:00 by admin · 2 comments
Owner

Originally created by @HTMLGuyLLC on GitHub (Mar 14, 2017).

Originally assigned to: @Ocramius on GitHub.

When using symfony's doctrine command line command to generate entities from an existing database, if a column starts with a number, it creates a property in the entity that starts with that number which is invalid PHP and causes errors. I suggest either a) throwing an error during generation for the user to change the column name or b) converting that number to the word (2 = two).

Originally created by @HTMLGuyLLC on GitHub (Mar 14, 2017). Originally assigned to: @Ocramius on GitHub. When using symfony's doctrine command line command to generate entities from an existing database, if a column starts with a number, it creates a property in the entity that starts with that number which is invalid PHP and causes errors. I suggest either a) throwing an error during generation for the user to change the column name or b) converting that number to the word (2 = two).
admin added the BugWon't FixCan't Fix labels 2026-01-22 15:08:16 +01:00
admin closed this issue 2026-01-22 15:08:16 +01:00
Author
Owner

@szymach commented on GitHub (May 12, 2017):

Entity generator is being removed (check an issue I submitted), so I doubt this will be resolved.

@szymach commented on GitHub (May 12, 2017): Entity generator is being removed (check an issue I [submitted](https://github.com/doctrine/doctrine2/issues/6418)), so I doubt this will be resolved.
Author
Owner

@Ocramius commented on GitHub (May 20, 2017):

There will always be impedance between what DBs support in identifier names, and what the ORM can pick for names.

This is one of those scenarios where you will simply need to manually define an entity, as any decision taken by the ORM may just lead to field naming collisions (replacing spaces with _, prefixing columns starting with invalid names, etc).

Closing as won't fix. Thanks @szymach for linking #6418

@Ocramius commented on GitHub (May 20, 2017): There will always be impedance between what DBs support in identifier names, and what the ORM can pick for names. This is one of those scenarios where you will simply need to manually define an entity, as any decision taken by the ORM may just lead to field naming collisions (replacing spaces with `_`, prefixing columns starting with invalid names, etc). Closing as `won't fix`. Thanks @szymach for linking #6418
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5461