Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2133

Issue with Query::iterate and query mixed results

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.1
    • Fix Version/s: 3.0
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Consider this code:

      $dql = "
          SELECT Page, Product.name
          FROM Dlayer\\Entity\\Page Page
          INNER JOIN Page.Product Product
          ";
      $q = ($em->createQuery($dql));
      foreach ($q->iterate() as $entry) {
        $page = $entry[0][0];
        $name = $entry[0]['name'];
      }
      

      This results with undefined index: 'name' for the second entry.

      First result keys are (notice just one array element with index 0):

      0
      array(2) {
        [0] =>
        int(0)
        [1] =>
        string(4) "name"
      } 
      

      but all others are different (notice two array elements with index 0 and the other one that is incrementing):

      the second one:
      0
      array(1) {
        [0] =>
        int(0)
      }
      1
      array(1) {
        [0] =>
        string(4) "name"
      } 
      the third one:
      0
      array(1) {
        [0] =>
        int(0)
      }
      2
      array(1) {
        [0] =>
        string(4) "name"
      } 
      
      

      What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?

        Issue Links

          Activity

          Oleg Namaka created issue -
          Oleg Namaka made changes -
          Field Original Value New Value
          Affects Version/s 2.2.1 [ 10194 ]
          Component/s ORM [ 10012 ]
          Oleg Namaka made changes -
          Description Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          First result keys are:
          {code}
          Array
          (
              [0] => 0
              [1] => name
          )
          {code}
          but all others are just:
          {code}
          Array
          (
              [0] => 0
          )
          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'nam'e for the second entry.

          First result keys are:
          {code}
          Array
          (
              [0] => 0
              [1] => name
          )
          {code}
          but all others are just:
          {code}
          Array
          (
              [0] => 0
          )
          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Oleg Namaka made changes -
          Description Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'nam'e for the second entry.

          First result keys are:
          {code}
          Array
          (
              [0] => 0
              [1] => name
          )
          {code}
          but all others are just:
          {code}
          Array
          (
              [0] => 0
          )
          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are:
          {code}
          Array
          (
              [0] => 0
              [1] => name
          )
          {code}
          but all others are just:
          {code}
          Array
          (
              [0] => 0
          )
          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Oleg Namaka made changes -
          Description Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are:
          {code}
          Array
          (
              [0] => 0
              [1] => name
          )
          {code}
          but all others are just:
          {code}
          Array
          (
              [0] => 0
          )
          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are:
          {code}
          0
          array(1) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different:
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Oleg Namaka made changes -
          Description Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are:
          {code}
          0
          array(1) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different:
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are (notice just one array element with index 0):
          {code}
          0
          array(1) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different ((notice just two array elements with index 0 and the other one that is incrementing)):
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Oleg Namaka made changes -
          Description Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are (notice just one array element with index 0):
          {code}
          0
          array(1) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different ((notice just two array elements with index 0 and the other one that is incrementing)):
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are (notice just one array element with index 0):
          {code}
          0
          array(1) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different (notice just two array elements with index 0 and the other one that is incrementing):
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Oleg Namaka made changes -
          Description Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are (notice just one array element with index 0):
          {code}
          0
          array(1) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different (notice just two array elements with index 0 and the other one that is incrementing):
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are (notice just one array element with index 0):
          {code}
          0
          array(1) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different (notice two array elements with index 0 and the other one that is incrementing):
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Oleg Namaka made changes -
          Description Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are (notice just one array element with index 0):
          {code}
          0
          array(1) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different (notice two array elements with index 0 and the other one that is incrementing):
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Consider this code:
          {code}
          $dql = "
              SELECT Page, Product.name
              FROM Dlayer\\Entity\\Page Page
              INNER JOIN Page.Product Product
              ";
          $q = ($em->createQuery($dql));
          foreach ($q->iterate() as $entry) {
            $page = $entry[0][0];
            $name = $entry[0]['name'];
          }
          {code}

          This results with undefined index: 'name' for the second entry.

          First result keys are (notice just one array element with index 0):
          {code}
          0
          array(2) {
            [0] =>
            int(0)
            [1] =>
            string(4) "name"
          }
          {code}
          but all others are different (notice two array elements with index 0 and the other one that is incrementing):
          {code}
          the second one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          1
          array(1) {
            [0] =>
            string(4) "name"
          }
          the third one:
          0
          array(1) {
            [0] =>
            int(0)
          }
          2
          array(1) {
            [0] =>
            string(4) "name"
          }

          {code}
          What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?
          Hide
          Benjamin Eberlei added a comment -

          This is a known issue that we don't have found a BC fix for and as I understand Guilherme Blanco requires considerable refactoring.

          Show
          Benjamin Eberlei added a comment - This is a known issue that we don't have found a BC fix for and as I understand Guilherme Blanco requires considerable refactoring.
          Benjamin Eberlei made changes -
          Fix Version/s 3.0 [ 10129 ]
          Benjamin Eberlei made changes -
          Link This issue is duplicated by DDC-1314 [ DDC-1314 ]

          This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

          • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2133, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Oleg Namaka
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: