I think I misjudged how Doctine handles these filters :( It seems that when filtering on "instanceof B", it will produce a query that will search for a row with `type = B`. Because B is in fact an abstract class, it will never exist in the db, so the query will indeed return an empty result set.
Seeing this in action, I think this is intended behavior, and your use-case is unfortunately not supported. If it would be supported, it would mean that Doctrine would have to figure out the inheritance graph beforehand, then create a query that will check not only `type = B`, but every child of B as well. That would impact performance, which is my guess as to why this isn't supported. I'm afraid the only solution right now is to filter on "instanceof D or instanceof E". PS: If your inheritance graph will get larger, it will pay of to use composition (together with associations) in stead of inheritance. -- Jasper N. Brouwer (@jaspernbrouwer) On 5 December 2014 at 10:41:15, Stefano Angaran ([email protected]) wrote: > Here it is. I've made some edit to reduce attributes number but the > structure is intact > > SELECT p0_.id AS id0, p0_.name AS name1, c1_.attr AS attr6, f3_.sku AS > sku7, c5_.foo AS foo8, c5_.bar AS bar9, p0_.type AS type12 FROM A p0_ LEFT > JOIN C c1_ ON p0_.id = c1_.id LEFT JOIN B f3_ ON p0_.id = f3_.id LEFT JOIN > D f4_ ON p0_.id = f4_.id WHERE p0_.type IN ('B') > > Only B is added in the WHERE expression. Am I doing something wrong or is > it how it's supposed to work? -- 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.
