Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-141

DQL with WHERE queries on Single Table Inheritance Entities fail

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0-ALPHA3
    • Fix Version/s: 2.0-ALPHA4
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      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)

        Activity

        Hide
        Roman S. Borschel added a comment -

        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.

        Show
        Roman S. Borschel added a comment - 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.
        Hide
        Nico Kaiser added a comment -

        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...

        Show
        Nico Kaiser added a comment - 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...
        Hide
        Roman S. Borschel added a comment -

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

        Show
        Roman S. Borschel added a comment - OK. Should be fixed now. Was a very trivial mistake. Now its covered in the tests.

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Nico Kaiser
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: