8000 DDC-3789: Paginator does not convert entity ids if they are value objects · Issue #4632 · doctrine/orm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
DDC-3789: Paginator does not convert entity ids if they are value objects #4632
Closed
@doctrinebot

Description

@doctrinebot

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
    }

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0