mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
'resolveMagicCall()' classify wrong? snake_case fields cannot be found #7222
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 @nsd4npo on GitHub (Sep 8, 2023).
Discussed in https://github.com/doctrine/orm/discussions/10938
Originally posted by nsd4npo September 8, 2023
Greetings,
I'm using a custom function within my
defaultRepositoryextender class calledfindOneOrCreateByField($fieldName, $fieldValue). Here's a snippet of how it works:However, I encountered an issue when using it with the parameters
testTimeand\DateTime("now"), which resulted in a "field not found" error. After some debugging, I discovered the source of the problem in this (shortened) code block:https://github.com/doctrine/orm/blob/2.16.x/lib/Doctrine/ORM/EntityRepository.php#L358-L360
In this context, the code uses classify on the field name, resulting in
TestTime. The subsequenthasFieldcheck fails because it's looking for atest_timefield instead ofTestTime.My conclusion is that for the
hasFieldcheck, it should use snake_case or tableize, while for thehasAssociationcheck, using classify is appropriate.Workaround in findOneOrCreateByField:
@derrabus commented on GitHub (Sep 11, 2023):
We don't need two threads for the same topic. Duplicate of #10938