mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Remove/Manage exception from getSingleIdentifierFieldName() #6007
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 @arviteri on GitHub (Jul 1, 2018).
Originally assigned to: @Ocramius on GitHub.
Feature Request
Summary
After searching around the source code and trying to implement a feature for EasyAdmin to work with composite keys, I realized that no bundle that calls
getSingleIdentifierFieldName()will work with composite keys due to the function throwing an exception.For example, the reason why EasyAdmin doesn't work with composite keys is because it calls this function and because Pagerfanta calls this function as well. I'd like to suggest removing the exception because I haven't found a case where it could cause a fatal error.
Another suggestion would be to provide an argument (boolean) to pass which determines if the exception will be thrown. For example the edited function could look like...
This way every bundle that currently calls this function will be safe and unchanged due to the default value provided in the parameter.
I think that removing the exception or using the suggested edit would allow for many bundles that use Doctrine ORM to be able to implement support for composite keys.
Lastly
I do think the best option would be to remove the exception and let the function return the first field instead of throwing the composite key exception.
@Ocramius commented on GitHub (Jul 1, 2018):
I fear that this is an X/Y question.
The exception is the correct outcome here. You cannot get a single identifier for something that has more than one identifier, and the Doctrine paginator can't operate on multiple identifier fields anyway.
Instead, the correct resolution is to NOT rely on this method at all when the mappings aren't known upfront.
Closing as
invalidhere.@arviteri commented on GitHub (Jul 2, 2018):
Thanks for clearing that up