Skip to content

Loading…

DDC-141: DQL with WHERE queries on Single Table Inheritance Entities fail #2033

Closed
doctrinebot opened this Issue · 4 comments

1 participant

@doctrinebot

Jira issue originally created by user nicokaiser:

The ORM query builder seems to be broken for Single Table Inheritance with discriminator.

When using inheritance like here:
http://www.doctrine-project.org/documentation/manual/2_0/en/inheritance-mapping#single-table-inheritance

Queries with WHERE fail:

SELECT p FROM MyProject\Model\Person p WHERE p.id = 1

This translates to this SQL:

SELECT p0*.id AS id0, p0_.discr AS discr1 FROM person p0_ WHERE p0_.id = 1 p0*.discr IN ('', 'person', 'employee')

(AND is missing after p0_.id = 1)

@doctrinebot

Comment created by romanb:

Thanks for reporting this. I'm just wondering where the empty string in the IN clause comes from? I dont seem to be able to reproduce that bit.

@doctrinebot

Comment created by nicokaiser:

Argh, ignore the empty string, it is

SELECT p0*.id AS id0, p0_.discr AS discr1 FROM person p0_ WHERE p0_.id = 1 p0*.discr IN ('person', 'employee')

My initial example was a superclass that did not appear in the DiscriminatorMap...

@doctrinebot

Comment created by romanb:

OK. Should be fixed now. Was a very trivial mistake. Now its covered in the tests.

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.0-ALPHA4 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.