orm: ArrayCollection->matching() not working anymore with Criteria->eq('id', $number)
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!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 27 (21 by maintainers)
Commits related to this issue
- GH-9109 - ArrayCollection->matching() not working anymore with Criteria->eq('id', $number) — committed to armenio/doctrine-orm by armenio 3 years ago
- In attempt to resolve https://github.com/doctrine/orm/issues/9109 — committed to armenio/doctrine-orm by armenio 3 years ago
- In attempt to resolve https://github.com/doctrine/orm/issues/9109 Infer type from field instead of column getTypeOfColumn() relies on getTypeOfField(), and does not suffer from mismatching issues ca... — committed to armenio/doctrine-orm by armenio 3 years ago
- Infer type from field instead of column getTypeOfColumn() relies on getTypeOfField(), and does not suffer from mismatching issues caused by quoting, because you cannot quote a field. Since a field ca... — committed to armenio/doctrine-orm by armenio 3 years ago
As I wrote: “it persist in v2.10.1”. (-;
@greg0ire I found! What is the next step? I don’t know the flow. please let me know what i need to know here is the result of git bisect:
Screenshot:
@armenio assuming this used to work in the past, you could use
git bisect
to find the commit that breaks your test.@Tagirijus please provide a reproducer. I took some personal time to try to reproduce and fix your issue but instead I ended up showing that it’s working fine.
Fixed, nvm it just exposes that it’s working fine and this issue should be closed to me 😉 .
@greg0ire @Tagirijus isn’t this fixed?