NativeQuery#execute() processes parameters for object parameters, even if a type is specified during setParameter() calls #6666

Open
opened 2026-01-22 15:36:42 +01:00 by admin · 2 comments
Owner

Originally created by @Ocramius on GitHub (Mar 26, 2021).

Similar to https://github.com/doctrine/orm/issues/7527

Calling NativeQuery#setParameter('foo', new \stdClass(), MyType::NAME) will lead to the ORM attempting to load class metadata for stdClass.

c8f2f61ea1/lib/Doctrine/ORM/NativeQuery.php (L72)

This is avoidable by short-circuiting this logic, and calling NativeQuery#processParameterValue() only when $parameter->getType() is not provided.

c8f2f61ea1/lib/Doctrine/ORM/NativeQuery.php (L70-L79)

Originally created by @Ocramius on GitHub (Mar 26, 2021). Similar to https://github.com/doctrine/orm/issues/7527 Calling `NativeQuery#setParameter('foo', new \stdClass(), MyType::NAME)` will lead to the ORM attempting to load class metadata for `stdClass`. https://github.com/doctrine/orm/blob/c8f2f61ea14e05c8f9a0da23467f3ca6a07d0173/lib/Doctrine/ORM/NativeQuery.php#L72 This is avoidable by short-circuiting this logic, and calling `NativeQuery#processParameterValue()` only when `$parameter->getType()` is not provided. https://github.com/doctrine/orm/blob/c8f2f61ea14e05c8f9a0da23467f3ca6a07d0173/lib/Doctrine/ORM/NativeQuery.php#L70-L79
Author
Owner

@beberlei commented on GitHub (Mar 28, 2021):

This whole parameter processing code got way out hand, this code block should execute the same logic that Query has for resolveParameterValue. This checks if a type is used before and short circuits the whole logic correctly.

@beberlei commented on GitHub (Mar 28, 2021): This whole parameter processing code got way out hand, this code block should execute the same logic that `Query` has for `resolveParameterValue`. This checks if a type is used before and short circuits the whole logic correctly.
Author
Owner

@dreis2211 commented on GitHub (Jan 16, 2026):

Hi 👋 Is there any plan to address this inconsistency? :)

@dreis2211 commented on GitHub (Jan 16, 2026): Hi 👋 Is there any plan to address this inconsistency? :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6666