Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ro0NL opened this issue Sep 5, 2024 · 11 comments
Closed

Comments

@ro0NL
Copy link

ro0NL commented 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
@ro0NL
Copy link
Author

ro0NL commented 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.

@greg0ire
Copy link
Member

greg0ire commented Sep 5, 2024

A native query you say?

im not sure about the related commit here.

Try reverting the one in my link please.

@ro0NL
Copy link
Author

ro0NL commented Sep 5, 2024

Thanks! We're skipping processParameterValue now, thus getSingleIdentifierValue

@ro0NL
Copy link
Author

ro0NL commented Sep 5, 2024

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

@greg0ire
Copy link
Member

greg0ire commented Sep 5, 2024

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

@ro0NL
Copy link
Author

ro0NL commented 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
Copy link
Author

ro0NL commented Sep 5, 2024

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

@ro0NL ro0NL changed the title 2.19.7 breaks proxy parameters 2.19.7 breaks entity parameters when set from query-builder to native-query Sep 5, 2024
@stof
Copy link
Member

stof commented Sep 5, 2024

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

@ro0NL
Copy link
Author

ro0NL commented Sep 5, 2024

Doctrine\ORM\Query\Parameter {#19011 ▼
  -name: "products"
  -value: array:1 [▶]
  -type: 102
  -typeSpecified: false
}

But after transfering from QB to native query, it becomes:

      -type: 102
      -typeSpecified: true

So we ignore typeSpecified when transfering, which is an implementation bug on our side. Unless it should be considered in Parameter::getType actually ...

@ro0NL
Copy link
Author

ro0NL commented Sep 5, 2024

possible userland patch:

- $native->setParameter($index, $p->getValue(), $p->getType());
+ $native->setParameter($index, $p->getValue(), $p->typeWasSpecified() ? $p->getType() : null);

@ro0NL
Copy link
Author

ro0NL commented Sep 6, 2024

i've applied the userland patch. Let's consider this an edge case, till further notice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants