Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-442

Break the query building with multiple from parts

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.4
    • Component/s: None
    • Security Level: All
    • Labels:

      Description

      For example:

      $queryBuilder
          ->select('DISTINCT c.id')
          ->from('Campaigns', 'c')
          ->leftJoin('c', 'CampaignOperations', 'od', 'od.campaignId = c.id AND od.operation = :operation')
          ->from('BannerGroups', 'bg')
          ->innerJoin('bg', 'BannerGroupStrategies', 'bgs', 'bgs.groupId = bg.id AND bgs.advSystem = :system')
          ->where('bg.campaignId = c.id');
      

      Builded the query:

      SELECT DISTINCT c.id FROM Campaigns s 
        LEFT JOIN CampaignOperations od ON (od.campaignId = c.id AND od.operation = :operation)
        INNER JOIN BannerGroupStrategies bgs ON (bgs.groupId = bg.id AND bgs.advSystem = :system), 
        BannerGroups bg
        WHERE (bg.campaignId = c.id)
      

      If this query execute on mysql, we get error:
      SQLSTATE[42S22]: Column not found: 1054 Unknown column 'bg.id' in 'on clause'

      Expected result:

      SELECT DISTINCT c.id FROM Campaigns s 
        LEFT JOIN CampaignOperations od ON (od.campaignId = c.id AND od.operation = :operation),
        BannerGroups bg
        INNER JOIN BannerGroupStrategies bgs ON (bgs.groupId = bg.id AND bgs.advSystem = :system)
        WHERE (bg.campaignId = c.id)
      

      Regression after patch https://github.com/doctrine/dbal/pull/175

        Activity

        Show
        Fabio B. Silva added a comment - Fixed by : https://github.com/doctrine/dbal/commit/99574240f332a814ec193b6e7a88abb6a457f061
        Show
        Denis Vasilev added a comment - https://github.com/doctrine/dbal/pull/270

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Denis Vasilev
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: