Doctrine 1
  1. Doctrine 1
  2. DC-452

Doctrine_RawSql->parseDqlQueryPart() using $this->_sqlParts

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: Query
    • Labels:
      None
    • Environment:
      Server is CentOS, running PHP5.2.x, Symfony 1.4, Doctrine 1.2

      Description

      Current definition of Doctrine_RawSql->parseDqlQueryPart() and use of Doctrine_Query_Abstract->orWhere() results in "AND WHERE" in query.

      DQL Example:
      $q->select('distinct p.*')
      ->from('Post p
      LEFT JOIN
      Post_Project pp ON (p.id=pp.post_id)
      LEFT JOIN
      Project_User pu USING (project_id)
      LEFT JOIN
      Post_User puu ON (p.id=puu.post_id)')
      ->addComponent('p', 'Post p')
      ->where('p.created_by = ?', $userId)
      ->orWhere('pu.user_id = ?', $userId)
      ->orWhere('puu.user_id = ?', $userId)
      ->orderBy('p.updated_at DESC');

      Results in:
      SELECT p.id AS p__id FROM Post p LEFT JOIN Post_Project pp ON (p.id=pp.post_id) LEFT JOIN Project_User pu USING (project_id) LEFT JOIN Post_User puu ON (p.id=puu.post_id) WHERE p.created_by = '4' AND pu.user_id = '4' AND puu.user_id = '4' ORDER BY p.updated_at DESC

      I drilled down to the source of the problem and:

      Doctrine_RawSql->parseDqlQueryPart()

      is using:

      $this->_sqlParts

      should be using:

      $this->_dqlParts

      or displaying a note that orWhere() officially does not work with Doctrine_RawSql.

        Activity

        Hide
        Jonathan H. Wage added a comment -

        I tried the change you suggested and as I expected it breaks the test suite. Can you re-open if you have more information or a test case for us to play with? Thanks, Jon

        Show
        Jonathan H. Wage added a comment - I tried the change you suggested and as I expected it breaks the test suite. Can you re-open if you have more information or a test case for us to play with? Thanks, Jon

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Christian Blanquera
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: