Inconsistent (unexpected) matching behavior with One:Many referenced object / scalar
$applicableParts = $partCollection->matching(
Criteria::create()->where(Criteria::expr()->eq('partStatusType', \PartStatusType::Qualified))
);
The above doesn't work. Below does.
$applicableParts = $partCollection->matching(
Criteria::create()->where(Criteria::expr()->in('partStatusType', [\PartStatusType::Qualified]))
);
This seems like odd behavior. Perhaps some documentation would be helpful because on first pass it seems like that one would be able to use the eq() expression with a referenced object. However, that throws the
{
return new self(sprintf(
"Cannot match on %s::%s with a non-object value. Matching objects by id is " .
"not compatible with matching on an in-memory collection, which compares objects by reference.",
$class, $associationName
));
}
After playing around with this, I tried out the ->in() expression which seemed to work. Any reason why all matchers couldn't be updated to support the id of the entity itself?
@jackdpeterson could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing.
These tests can be used as example:
https://github.com/doctrine/collections/blob/42c4039eca9535e4f201f50d2695648658e9e5a8/tests/Doctrine/Tests/Common/Collections/CollectionTest.php#L22-L64