mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-220: 'Ambiguous column: 7 ERROR: column reference "created_by_person_id" is ambiguous at character 466' if ManyToMany through a mapping class is used which extends a base class #273
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Dec 21, 2009).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user mzach:
Using a many-to-many mapping with a separate class where each class extends a common base class, loading of the primary class succeeds whereas fetching related records results in a 'SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "created_by_person_id" is ambiguous at character 466' error.
Scenario:
As shown above, the class PropertyGroupMember is used to map Groups and Properties using an orderNumber as additional fields and all classes extends AbstractBase which holds the id, version number as relations to a Person class (not described here, consists of the usual fields firstname, lastname and so on).
Now, when using a simple DQL like the following:
the data is retrieved just fine, however iterating over the resulting PropertyGroups and accessing their $Properties results in the following SQL (which tries to lazy-load the data):
Now, the fields "created_by_person_id", "modified_by_person_id" and "deleted_by_person_id" are not prefixed with the corresponding table name and therefore ambiguous as both the property as well as the property_group_member table contain these fields.