Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Query Builder
-
Labels:None
Description
I noticed that the references() method does not support fields on embedded objects, as the argument to the preceding field() method will be passed into getFieldMapping() and trigger an exception. I suppose a solution would require multiple calls to getFieldMapping() in order to dive into the embedded object's class metadata.
To demonstrate, below is an example of a UserRepository class. The User document contains an embeddedObject that itself references another User:
class UserRepository extends DocumentRepository { public function findByEmbeddedObjectReference(User $user) { return $this->createQueryBuilder() ->field('embeddedObject.user.$id')->equals($user->getId()) // ->field('embeddedObject.user')->references($user) ->getQuery() ->execute(); } }
Using field()/equals() works fine as an alternative to references(), so there is no urgent need for this feature.
Activity
This list may be incomplete, as errors occurred whilst retrieving source from linked applications:
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=MODM-145, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
Hi
It seems that we have a problem with the temporary solution proposed :
Doctrine remove the "$id" part in our query :
obj->field('embedded.referenced.$id')->equals($reference->getId())will generate the query without "$id".
There is no problem when the reference is directly in the requested object.
Did someone experience this issue ?