2.19.7 breaks entity parameters when set from query-builder to native-query #7416

Closed
opened 2026-01-22 15:51:26 +01:00 by admin · 8 comments
Owner

Originally created by @ro0NL on GitHub (Sep 5, 2024).

BC Break Report

Q A
BC Break yes
Version 2.19.7

Summary

Given (AbstractQuery) $qb->execute($qb->getParameters()), if one of the parameters is a proxy entity, since 2.19.7 it produces:

Object of class Proxies\__CG__\... could not be converted to string
Originally created by @ro0NL on GitHub (Sep 5, 2024). <!-- Before reporting a BC break, please consult the upgrading document to make sure it's not an expected change: https://github.com/doctrine/orm/blob/2.9.x/UPGRADE.md --> ### BC Break Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes | Version | 2.19.7 #### Summary Given `(AbstractQuery) $qb->execute($qb->getParameters())`, if one of the parameters is a proxy entity, since 2.19.7 it produces: ``` Object of class Proxies\__CG__\... could not be converted to string ```
admin closed this issue 2026-01-22 15:51:27 +01:00
Author
Owner

@ro0NL commented on GitHub (Sep 5, 2024):

We have a native query ($native = $entityManager->createNativeQuery())

We then transfer original QB parameters to the native one;

foreach ($qb->getParameters() as $k => $p) {
    $native->setParameter($index, $p->getValue(), $p->getType());
    $index++;
}

I believe it's incompatible API, but im not sure about the related commit here.

@ro0NL commented on GitHub (Sep 5, 2024): We have a native query (`$native = $entityManager->createNativeQuery()`) We then transfer original QB parameters to the native one; ``` foreach ($qb->getParameters() as $k => $p) { $native->setParameter($index, $p->getValue(), $p->getType()); $index++; } ``` I believe it's incompatible API, but im not sure about the related commit here.
Author
Owner

@greg0ire commented on GitHub (Sep 5, 2024):

A native query you say?

im not sure about the related commit here.

Try reverting the one in my link please.

@greg0ire commented on GitHub (Sep 5, 2024): [A native query you say?](https://github.com/doctrine/orm/pull/11543) > im not sure about the related commit here. Try reverting the one in my link please.
Author
Owner

@ro0NL commented on GitHub (Sep 5, 2024):

Thanks! We're skipping processParameterValue now, thus getSingleIdentifierValue

@ro0NL commented on GitHub (Sep 5, 2024): Thanks! We're skipping `processParameterValue` now, thus `getSingleIdentifierValue`
Author
Owner

@ro0NL commented on GitHub (Sep 5, 2024):

The triggering call is $qb->setParameter('products', $products), where $products is an array of entities

@ro0NL commented on GitHub (Sep 5, 2024): The triggering call is `$qb->setParameter('products', $products)`, where $products is an array of entities
Author
Owner

@greg0ire commented on GitHub (Sep 5, 2024):

It's unclear to me if you've tried reverting the commit or not.

@greg0ire commented on GitHub (Sep 5, 2024): It's unclear to me if you've tried reverting the commit or not.
Author
Owner

@ro0NL commented on GitHub (Sep 5, 2024):

@greg0ire sorry!

yes, commenting out

//            if ($parameter->typeWasSpecified()) {
//                $parameters[$name] = $parameter->getValue();
//                $types[$name]      = $parameter->getType();
//
//                continue;
//            }

100% solves it.

I dont think it should be part of a patch release.

@ro0NL commented on GitHub (Sep 5, 2024): @greg0ire sorry! yes, commenting out ``` // if ($parameter->typeWasSpecified()) { // $parameters[$name] = $parameter->getValue(); // $types[$name] = $parameter->getType(); // // continue; // } ``` 100% solves it. I dont think it should be part of a patch release.
Author
Owner

@ro0NL commented on GitHub (Sep 5, 2024):

Of course, im also curious if we can maintain the current compatibility, since we rely on default infered typing.

@ro0NL commented on GitHub (Sep 5, 2024): Of course, im also curious if we can maintain the current compatibility, since we rely on default infered typing.
Author
Owner

@stof commented on GitHub (Sep 5, 2024):

What is $p->getType() in your case ?

@stof commented on GitHub (Sep 5, 2024): What is `$p->getType()` in your case ?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7416