Some days ago I faced an issue with the filtering of child entities. I'll
give you an example for easier understanding.
We have two entities
|-----------| |-----------------------------|
| Customer | | Project |
|----|------| |------|-------------|--------|
| id | name | | name | customer_id | status |
|----|------| |------|-------------|--------|
| 1 | A | | P1 | 1 | 1 |
|----|------| | P2 | 1 | 1 |
| P3 | 1 | 2 |
| P4 | 1 | 3 |
|------|-------------|--------|
$dql1 = 'SELECT customer, project
FROM Customer customer
JOIN Project project
WHERE customer.id = 1';
$dql2 = 'SELECT customer, project F
ROM Customer customer
JOIN Project project
WHERE customer.id = 1
AND project.status = 1';
Now if you execute both of the above queries, you will get the customer 'A'
with all its projects. The second condition of $dql2 is leveraged, because
Doctrine will return the same customer Object as in the first query holding
the four projects. I am sure that this is a known issue and maybe you would
think that possible solutions are to clear the entity manager, but this
will detach all entities loaded before.
Is there any other working solution ('REFRESH' hint could lead to dangerous
side effects, so this is no solution)?
I think Doctrine will have to care about the constitions when storing and
fetching entities from the cache, but this is not trivial I think.
What do you think?
--
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.