8000 ArrayCollection->matching() not working anymore with Criteria->eq('id', $number) · Issue #9109 · doctrine/orm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ArrayCollection->matching() not working anymore with Criteria->eq('id', $number) #9109
Closed
@Tagirijus

Description

@Tagirijus

Bug Report

Q A
BC Break yes
Version 2.9.6

Summary

It seems that something changed with the ->matching() method of an ArrayCollection. It persist in v2.10.1.

Current behavior

When I have an ArrayCollection I want to filter with matching and a Criteria, which has an expression like ->eq('id', $number) my script tells me something like:

"Could not resolve type of column "`id`" of class ..." and so on.

How to reproduce

Let's say you have an entity "work" with an ArrayCollection called "connectedalbums", which stores other entities like "album". I now want to access the album with the id "3" and would do it like this:

// $work is already fetched form the DB.

$criteria = new Criteria();
$criteria->where(Criteria::expr()->eq('id', 3));
$album = $work->getConnectedAlbums()->matching($criteria)->toArray();

if (!empty($album)) {
    $album = $album[0];
}

With this, PHP throws an Uncaught RuntimeException like mentioned above.

Expected behavior

I expect an ArrayCollection with ->matching() and the Criteria with the expression ->eq('id', $number) to give me the correct item from the ArrayCollection, whichs column id has the value, which is stored in $number. It worked like this in v2.9.5!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0