Jira issue originally created by user dadamssg:
If an entity uses a custom value object and DBAL type for its id, the value object is used as query parameters instead of the converted value.
Here is where $ids contains an array of value objects. This eventually gets set as parameter for the query here.
This leads to an exception like this:
bq. An exception occurred while executing 'SELECT a0_.id AS ID_0, a0_.created_at AS CREATED_AT_1, a0_.updated_at AS UPDATED_AT_2, a0_.name AS NAME_3, a0_.primary_image_id AS PRIMARY_IMAGE_ID_4, a0_.category_id AS CATEGORY_ID_5, a0_.created_by_id AS CREATED_BY_ID_6 FROM assets a0_ WHERE a0_.created_by_id = ? AND a0_.category_id = ? AND a0_.id IN (?, ?, ?)' with params [\"9369f64a-a978-4c5c-b403-baef2576285f\", \"2f8d4a66-47af-4b14-9a3d-54c1debd084c\", {}, {}, {}]:\n\nWarning: oci_bind_by_name(): Invalid variable used for bind
The 3 empty parameters are how my value objects are being wrongly represented.
I've fixed a similar issue in this pull request but I don't know how to go about fixing this in the Paginator.
One solution could be to only allow value objects for id's if the value object class has a **toString() method and another line gets added after the id objects are retrieved:
/****
* {@inheritdoc}
*/
public function getIterator()
{
// existing code
$ids = array_map('current', $subQuery->getScalarResult());
$ids = array_map('strval', $ids);
// existing code
}
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1436] was assigned:
https://github.com/doctrine/doctrine2/pull/1436
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1436] was merged:
https://github.com/doctrine/doctrine2/pull/1436
Any ideas how to do it without using __toString Method? I'm trying to implement UuidBinary. This occurs when passing array of id's objects
Doctrine uses a string representation of your object to create its internal identity map. No way around that, sorry.
@Ocramius alright then, thanks.
@NavyCoat did you found any solution?
@JCMais Sorry, nothing interesting.
I currently drop idea of migration to binary uuid. I was using mysql database. But from what I found somewhere, that can works with Postgres Database where UUID is there as a type. This mean that when you pass UUID as a string, Postgres will store it as Binary UUID. (You will see it as string but there is a binary).
If you find something interesting, please share your solution here :)
What would be an actual solution here?
Doctrine is using the __toString version to bind to a query, but here there's actually a database version and a "human readable" version, much like the types stuff. Binding anything that comes out of __toString seems wrong, it should use the type system. Am I missing something?
+1
Fixed by #7821