mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-2421: Many-To-Many relation creation failed when using non PK entity field #3036
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 (Apr 29, 2013).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user jedi_bc:
Given these entities :
I've got a domain, some web sites per domain and websgroups which group web sites. I want to be sure in my database that a web group from a domain D can contain only web sites from the very same domain but when calling the console tool for creating my schema it raise :
It's because domain is already an association to an entity which and is not part of the primary key.
I've quick fixed
getDefiningClassfromDoctrine\ORM\Tools\SchemaToolto make it work but i really don't know if it's the proper way :@doctrinebot commented on GitHub (Apr 29, 2013):
Comment created by @FabioBatSilva:
[~jedi_bc] Except for some CS this fix seems good.
If you have time you can send as pull request
@doctrinebot commented on GitHub (Apr 30, 2013):
Comment created by jedi_bc:
I've start making a PR and a test case but it is linked to http://www.doctrine-project.org/jira/browse/DDC-2413
I'm looking in making a proper fix to DDC-2413 first.
@doctrinebot commented on GitHub (May 1, 2013):
Comment created by @beberlei:
You cannot use a reference column that is not a primary key. Doctrine does not support this.
@doctrinebot commented on GitHub (May 1, 2013):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Sep 10, 2013):
Comment created by bavo:
I stumbled on this issue when experiencing a similar bug.
There is something seriously wrong with the referencedColumn in a ManyToMany relationship.
When you use a PK as 'id' and set your referenced column to 'id' everything is fine.
But when you use 'productId' as PK and reference it properly creation fails because "column 'id' doens't exists in table", which is very strange. After introducing a bogus column 'id' to the entity, but still referencing 'productId' a linking table is created but it has FK's to 'id' not to productId. When changing the referenced column to 'bogus' the creation also fails because: "column 'bogus' doesn't exists in table".
To me doctrine checks the the referencedColumn for existence but after that just creates everything assuming the default PK 'id'.