Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-1940

Doctrine DQL: erroneous sql generation from dql join with "WITH" or "WHERE" clause


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: DQL
    • Security Level: All
    • Labels:
    • Environment:
      LAMP, debian squeeze


      I'm having big troubles while developing a quietly advanced DQL query for a tiny DMS: The schema: DmsObject is a superclass for which two subclasses exist (document and folder) UserRights and GroupRight (which are associative entities in the db, pointing respectively to user and group tables). User and Group represent (obvious) the dms "actors".

      SELECT o, ur, gr 
      from module\EDMS\business\DmsObject o 
      join o.userRights ur 
      join o.groupRights gr
      WHERE o.ownerUser=ur.user
      AND o.ownerGroup=gr.group

      The WHERE condition is WRONG! Doctrine switches the two tables. I've already checked the mapping (it's ok!) and checked also where the fk's point in the database (ok!).

      LEFT JOIN dms_folder d1_ 
          ON d0_.id = d1_.id 
      LEFT JOIN dms_document d2_ 
          ON d0_.id = d2_.id 
      INNER JOIN dms_user_object_rights d3_ 
          ON d0_.id = d3_.document_id 
      INNER JOIN dms_group_object_rights d4_ 
          ON d0_.id = d4_.document_id 
      WHERE d0_.sys_group_owner = d3_.user_id 
          AND d0_.sys_user_owner = d4_.group_id

      This seems to be a bug in the DQL translator.

        Issue Links



            • Assignee:
              ocramius Marco Pivetta
              noise085 Enea Bette
            • Votes:
              1 Vote for this issue
              8 Start watching this issue


              • Created: