Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.4
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None
    • Environment:
      Symfony 2.3.3, MSSQL 2008 R2

      Description

      Expected behaviour: get 5 countries in africa (and other continents with countries)
      Actual behaviour: getting 1 country in africa (and other continents with countries)

      // Schema:
      One Continent to Many Country
      (Continent is called Region in the schema)

      // DQL

      $query = $em->createQuery("
      	SELECT continent, country
      	FROM Geo:Continent continent
      	JOIN continent.countries country
      	ORDER BY continent.order ASC, country.name ASC
      ");
      

      // Filter

      <?php
      namespace MyVendor\MyBundle\DoctrineFilter;
      
      use Doctrine\ORM\Mapping\ClassMetaData,
          Doctrine\ORM\Query\Filter\SQLFilter;
      
      class VioCountryFilter extends SQLFilter {
      
      	public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
      		if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
      			return $targetTableAlias . '.isVioLand = 1';
      		} else {
      			return '';
      		}
      	}
      }
      

      // Filter config (in Symfony 2.3) YAML

      doctrine:
          orm:
              entity_managers:
                  default:
                      filters:
                          vio_country:
                              class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                              enabled: true
      

      // Generated - SQL

      SELECT 
        r0_.id AS id0, 
        r0_.Region AS Region1, 
        r0_.Sort AS Sort2, 
        l1_.LandId AS LandId3, 
        l1_.IsVioLand AS IsVioLand4, 
        l1_.Max AS Max22, 
        l1_.Min AS Min23, 
        l1_.LandNaam AS LandNaam24, 
        l1_.Population AS Population29, 
        l1_.RegionId AS RegionId35 
      FROM 
        Region r0_ WITH (NOLOCK) 
        INNER JOIN Land l1_ ON r0_.id = l1_.RegionId 
        AND (l1_.isVioLand = 1) 
      ORDER BY 
        r0_.Sort ASC, 
        l1_.LandNaam ASC
      

      // Executed SQL in Management Studio:
      This is only displaying the 6th continent: Africa (do not show other continents)
      (Sort goes from 1 to 6)

      id0 Region1 Sort2 LandId3 IsVioLand4 Max22 Min23 LandNaam24 Population29 RegionId35
      1 Africa 6 5 1 24.0 13.0 Algeria 37762962 1
      1 Africa 6 6 1 27.0 17.0 Egypt 79392466 1
      1 Africa 6 10 1 23.0 13.0 Morocco 32059424 1
      1 Africa 6 14 1 22.0 12.0 South Africa 50586757 1
      1 Africa 6 13 1 24.0 15.0 Tunisia 10673800 1

      HAS 5 COUNTRIES IN AFRICA !!!

      // Dump = The actual behaviour

      $continents = $query->getResult();
      var_dump($continents[5]);
      

      (also made this dump shorter)

      class MyVendor\Entity\Geo\Continent#1290 (4) {
        protected $id =>
        int(1)
        protected $countries =>
        class Doctrine\ORM\PersistentCollection#1292 (9) {
          private $snapshot =>
          array(1) { // 				<-- HAS 1 COUNTRIES IN AFRICA !!!
            [0] =>
            class MyVendor\Entity\Geo\Country#1293 (38) {
              ...
            }
          }
          private $coll =>
          class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
            private $_elements =>
            array(1) { // 				<-- HAS 1 COUNTRIES IN AFRICA !!!
              ...
            }
          }
        }
        protected $name =>
        string(6) "Africa"
        protected $order =>
        int(6)
      }
      

        Activity

        Flip created issue -
        Flip made changes -
        Field Original Value New Value
        Description // Schema:
        One Country to Many Continents (Called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]);
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        // Schema:
        One Country to Many Continents (Called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]); (count from 0 to 5, africa is nr 6. Can be verified by $name below)
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Flip made changes -
        Summary Hydrating going wrong when using Filter Hydrate not working correctly
        Flip made changes -
        Description // Schema:
        One Country to Many Continents (Called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]); (count from 0 to 5, africa is nr 6. Can be verified by $name below)
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Expected behaviour: get 5 countries in africa
        Actual behaviour: getting 1 country in africa

        // Schema:
        One Country to Many Continents (Called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]);
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Flip made changes -
        Description Expected behaviour: get 5 countries in africa
        Actual behaviour: getting 1 country in africa

        // Schema:
        One Country to Many Continents (Called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]);
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Expected behaviour: get 5 countries in africa
        Actual behaviour: getting 1 country in africa

        // Schema:
        One Country to Many Continents (Called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump = The actual behaviour
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]);
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Flip made changes -
        Description Expected behaviour: get 5 countries in africa
        Actual behaviour: getting 1 country in africa

        // Schema:
        One Country to Many Continents (Called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump = The actual behaviour
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]);
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Expected behaviour: get 5 countries in africa
        Actual behaviour: getting 1 country in africa

        // Schema:
        One Continent to Many Country
        (Continent is called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump = The actual behaviour
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]);
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Flip made changes -
        Description Expected behaviour: get 5 countries in africa
        Actual behaviour: getting 1 country in africa

        // Schema:
        One Continent to Many Country
        (Continent is called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump = The actual behaviour
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]);
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Expected behaviour: get 5 countries in africa (and other continents with countries)
        Actual behaviour: getting 1 country in africa (and other continents with countries)

        // Schema:
        One Continent to Many Country
        (Continent is called Region in the schema)

        // DQL
        {code}
        $query = $em->createQuery("
        SELECT continent, country
        FROM Geo:Continent continent
        JOIN continent.countries country
        ORDER BY continent.order ASC, country.name ASC
        ");
        {code}

        // Filter
        {code}
        <?php
        namespace MyVendor\MyBundle\DoctrineFilter;

        use Doctrine\ORM\Mapping\ClassMetaData,
            Doctrine\ORM\Query\Filter\SQLFilter;

        class VioCountryFilter extends SQLFilter {

        public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) {
        if ($targetEntity->name === 'MyVendor\Entity\Geo\Country') {
        return $targetTableAlias . '.isVioLand = 1';
        } else {
        return '';
        }
        }
        }
        {code}

        // Filter config (in Symfony 2.3) YAML
        {code}
        doctrine:
            orm:
                entity_managers:
                    default:
                        filters:
                            vio_country:
                                class: MyVendor\MyBundle\DoctrineFilter\VioCountryFilter
                                enabled: true
        {code}

        // Generated - SQL
        {code:sql}
        SELECT
          r0_.id AS id0,
          r0_.Region AS Region1,
          r0_.Sort AS Sort2,
          l1_.LandId AS LandId3,
          l1_.IsVioLand AS IsVioLand4,
          l1_.Max AS Max22,
          l1_.Min AS Min23,
          l1_.LandNaam AS LandNaam24,
          l1_.Population AS Population29,
          l1_.RegionId AS RegionId35
        FROM
          Region r0_ WITH (NOLOCK)
          INNER JOIN Land l1_ ON r0_.id = l1_.RegionId
          AND (l1_.isVioLand = 1)
        ORDER BY
          r0_.Sort ASC,
          l1_.LandNaam ASC
        {code}

        // Executed SQL in Management Studio:
        This is only displaying the 6th continent: Africa (do not show other continents)
        (Sort goes from 1 to 6)

        ||id0||Region1||Sort2||LandId3||IsVioLand4||Max22||Min23||LandNaam24||Population29||RegionId35||
        |1|Africa|6|5|1|24.0|13.0|Algeria|37762962|1|
        |1|Africa|6|6|1|27.0|17.0|Egypt|79392466|1|
        |1|Africa|6|10|1|23.0|13.0|Morocco|32059424|1|
        |1|Africa|6|14|1|22.0|12.0|South Africa|50586757|1|
        |1|Africa|6|13|1|24.0|15.0|Tunisia|10673800|1|

        HAS 5 COUNTRIES IN AFRICA !!!

        // Dump = The actual behaviour
        {code}
        $continents = $query->getResult();
        var_dump($continents[5]);
        {code}
        (also made this dump shorter)

        {code}
        class MyVendor\Entity\Geo\Continent#1290 (4) {
          protected $id =>
          int(1)
          protected $countries =>
          class Doctrine\ORM\PersistentCollection#1292 (9) {
            private $snapshot =>
            array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
              [0] =>
              class MyVendor\Entity\Geo\Country#1293 (38) {
                ...
              }
            }
            private $coll =>
            class Doctrine\Common\Collections\ArrayCollection#1291 (1) {
              private $_elements =>
              array(1) { // <-- HAS 1 COUNTRIES IN AFRICA !!!
                ...
              }
            }
          }
          protected $name =>
          string(6) "Africa"
          protected $order =>
          int(6)
        }
        {code}
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Flip
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: