[PR #280] 2.1.x #7963

Closed
opened 2026-01-22 15:57:45 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/280

State: closed
Merged: Yes


Make Reverse Engineering to support Primary Keys as Foreign Keys.

The origin of the problem:

While parsing database Doctrine2 creates 2 separate arrays - "field mappings" and "association mappings".
If the field is within table foreign keys, it goes to "association mappings", otherwise it goes to "field mappings".

With primary keys as foreign keys Doctrine2 behaves incorrectly - it adds it both to "field mappings" and "association mappings", creating a nasty MappingException::duplicateFieldMapping

Reworked the code so it adds it only to the "association mappings", creating a OneToOne mapping type.

I wonder why so few attention is payed to reverse engineering in the project.

When you introspect database it only creates unidirectional mappings, so you have to manually create an
inverse in other entities.

In Doctrine 1.x it was much-much better.
Reverse engineering is not evil. Is a thing really very important in many situations when you a have a huge existing database structure.

**Original Pull Request:** https://github.com/doctrine/orm/pull/280 **State:** closed **Merged:** Yes --- Make Reverse Engineering to support Primary Keys as Foreign Keys. The origin of the problem: While parsing database Doctrine2 creates 2 separate arrays - "field mappings" and "association mappings". If the field is within table foreign keys, it goes to "association mappings", otherwise it goes to "field mappings". With primary keys as foreign keys Doctrine2 behaves incorrectly - it adds it both to "field mappings" and "association mappings", creating a nasty MappingException::duplicateFieldMapping Reworked the code so it adds it only to the "association mappings", creating a OneToOne mapping type. I wonder why so few attention is payed to reverse engineering in the project. When you introspect database it only creates unidirectional mappings, so you have to manually create an inverse in other entities. In Doctrine 1.x it was much-much better. Reverse engineering is not evil. Is a thing really very important in many situations when you a have a huge existing database structure.
admin added the pull-request label 2026-01-22 15:57:45 +01:00
admin closed this issue 2026-01-22 15:57:45 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7963