I figured out that I am getting the fields wrong way. I started using
PARTIAL functionality.
On request `/api/employee?fields=id,division` the DQL looks like this:
SELECT partial u.{id,division} FROM Project\BackendBundle\Entity\Employee u
And the result is:
array (size=1)
0 =>
array (size=3)
'division' =>
object(Project\BackendBundle\Entity\Kategorija)[672]
private 'id' => int 20
private 'name' => string 'division1' (length=9)
'position' =>
object(Project\BackendBundle\Entity\Position)[629]
private 'id' => int 15
private 'name' => string 'Manager' (length=7)
'id' => int 890
You can see that I get the requested entity fields + all associated fields,
no matter that I requested only one associated field.
How to get only requested associated fields while using partial?
2014 m. gruodis 3 d., trečiadienis 11:28:20 UTC+2, Jàπ (Jasper N. Brouwer)
rašė:
>
> Then you'll need to select a root alias ;)
> I'm guessing it is `u`.
>
> PS: As a side question, why are you building your query according to
> mapping metadata? Are you not in control of what associations are mapped?
>
> --
> Jasper N. Brouwer
> (@jaspernbrouwer)
>
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.