'resolveMagicCall()' classify wrong? snake_case fields cannot be found #10938
Unanswered
nsd4npo
asked this question in
Support Questions
Replies: 1 comment 1 reply
-
tbh, your "workaround" looks better than the actual code. Assembling a method name just to hit the correct magic call resolution does not make sense to me. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings,
I'm using a custom function within my
defaultRepository
extender class calledfindOneOrCreateByField($fieldName, $fieldValue)
. Here's a snippet of how it works:However, I encountered an issue when using it with the parameters
testTime
and\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 subsequenthasField
check fails because it's looking for atest_time
field instead ofTestTime
.My conclusion is that for the
hasField
check, it should use snake_case or tableize, while for thehasAssociation
check, using classify is appropriate.Workaround in findOneOrCreateByField:
Beta Was this translation helpful? Give feedback.
All reactions