DDC-1440: Doctrine2 is not able to manage correctly a FK based on a unique string which is not a PK on its table #1809

Closed
opened 2026-01-22 13:26:44 +01:00 by admin · 6 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 20, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user sibok:

Doctrine2 is not able to manage correctly a FK based on a unique string which is not a PK on its table. Tables are created successfully but data is not managed properly. I'm attaching some Entities and Fixture files in order to test it :)

Originally created by @doctrinebot on GitHub (Oct 20, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user sibok: Doctrine2 is not able to manage correctly a FK based on a unique string which is not a PK on its table. Tables are created successfully but data is not managed properly. I'm attaching some Entities and Fixture files in order to test it :)
admin added the Bug label 2026-01-22 13:26:44 +01:00
admin closed this issue 2026-01-22 13:26:45 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 20, 2011):

Comment created by @beberlei:

Could you run "doctrine.php orm:validate-schema" ? I think this will give you an error that this is not possible. Doctrine can only work with foreign keys through primary keys. A workaround for this is making doctrine belive that the unique field is the identifier and that the real id field is just a regular field.

@doctrinebot commented on GitHub (Oct 20, 2011): Comment created by @beberlei: Could you run "doctrine.php orm:validate-schema" ? I think this will give you an error that this is not possible. Doctrine can only work with foreign keys through primary keys. A workaround for this is making doctrine belive that the unique field is the identifier and that the real id field is just a regular field.
Author
Owner

@doctrinebot commented on GitHub (Oct 20, 2011):

Comment created by sibok:

Hi, i'm using doctrine2 through symfony2 and it does not provide the command to validate the schema. I think it was removed some time ago. Could you explain a liitle bit how to accomplish your workaround? Right now i've done sme workarounds to avoid that issue but i think it's a feature which is used very often.
Thanks a lot :)

PD: Entities and fixtures are working fine.

@doctrinebot commented on GitHub (Oct 20, 2011): Comment created by sibok: Hi, i'm using doctrine2 through symfony2 and it does not provide the command to validate the schema. I think it was removed some time ago. Could you explain a liitle bit how to accomplish your workaround? Right now i've done sme workarounds to avoid that issue but i think it's a feature which is used very often. Thanks a lot :) PD: Entities and fixtures are working fine.
Author
Owner

@doctrinebot commented on GitHub (Oct 27, 2011):

Comment created by @beberlei:

You can re-add the command by just adding a plain command into your own bundle that extends from doctrines validate schema and extend the "execute" method to inject the EntityManager from the DIC correctly.

@doctrinebot commented on GitHub (Oct 27, 2011): Comment created by @beberlei: You can re-add the command by just adding a plain command into your own bundle that extends from doctrines validate schema and extend the "execute" method to inject the EntityManager from the DIC correctly.
Author
Owner

@doctrinebot commented on GitHub (Oct 31, 2011):

Comment created by @beberlei:

This is an invalid mapping.

You can only map join-columns of associations to primary keys.

@doctrinebot commented on GitHub (Oct 31, 2011): Comment created by @beberlei: This is an invalid mapping. You can only map join-columns of associations to primary keys.
Author
Owner

@doctrinebot commented on GitHub (Oct 31, 2011):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Oct 31, 2011): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 4 attachments from Jira into https://gist.github.com/97f4f992872365aa4e27

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 4 attachments from Jira into https://gist.github.com/97f4f992872365aa4e27 - [11073_Permission.php](https://gist.github.com/97f4f992872365aa4e27#file-11073_Permission-php) - [11074_User.php](https://gist.github.com/97f4f992872365aa4e27#file-11074_User-php) - [11075_permission_1308995187.php](https://gist.github.com/97f4f992872365aa4e27#file-11075_permission_1308995187-php) - [11076_user_1308995187.php](https://gist.github.com/97f4f992872365aa4e27#file-11076_user_1308995187-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1809