Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1150

BasicEntityPersister::expandParameters does not check assiciation mapping when expanding parameters

    Details

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

      Description

      If you try to find entities, filtering them by field with association mapping (ManyToOne) and use an array as a filter argument it will not work:

          $em->getRepository('EntityBundle:Entity')->findBy(array('child' => array(1,2,3)));
          8 Array to string conversion vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php 595
      

      I fixed method BasicEntityPersister::expandParameters:

      Index: ../vendor/doctrine/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
      ===================================================================
      @@ -1300,6 +1300,9 @@
                   if (isset($this->_class->fieldMappings[$field])) {
                       $type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
                   }
      +            if (isset($this->_class->associationMappings[$field])) {
      +                $type = $this->_class->associationMappings[$field]['type'];
      +            }
                   if (is_array($value)) {
                       $type += Connection::ARRAY_PARAM_OFFSET;
                   }
      

        Activity

        Konstantin created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Description If you try to find entities, filtering them by field with association mapping (ManyToOne) and use an array as a filter argument it will not work:

        {quote}
            $em->getRepository('EntityBundle:Entity')->findBy(array('child' => array(1,2,3)));
            8 Array to string conversion vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php 595
        {quote}

        I fixed method BasicEntityPersister::expandParameters:

        {quote}

        Index: ../vendor/doctrine/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
        ===================================================================
        @@ -1300,6 +1300,9 @@
                     if (isset($this->_class->fieldMappings[$field])) {
                         $type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
                     }
        + if (isset($this->_class->associationMappings[$field])) {
        + $type = $this->_class->associationMappings[$field]['type'];
        + }
                     if (is_array($value)) {
                         $type += Connection::ARRAY_PARAM_OFFSET;
                     }
        {quote}
        If you try to find entities, filtering them by field with association mapping (ManyToOne) and use an array as a filter argument it will not work:

        {code}
            $em->getRepository('EntityBundle:Entity')->findBy(array('child' => array(1,2,3)));
            8 Array to string conversion vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php 595
        {code}

        I fixed method BasicEntityPersister::expandParameters:

        {code}

        Index: ../vendor/doctrine/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
        ===================================================================
        @@ -1300,6 +1300,9 @@
                     if (isset($this->_class->fieldMappings[$field])) {
                         $type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
                     }
        + if (isset($this->_class->associationMappings[$field])) {
        + $type = $this->_class->associationMappings[$field]['type'];
        + }
                     if (is_array($value)) {
                         $type += Connection::ARRAY_PARAM_OFFSET;
                     }
        {code}
        Guilherme Blanco made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Benjamin Eberlei [ beberlei ] Guilherme Blanco [ guilhermeblanco ]
        Fix Version/s 2.2-DEV [ 10157 ]
        Fix Version/s Git Master [ 10100 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12635 ] jira-feedback [ 14859 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14859 ] jira-feedback2 [ 16723 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 16723 ] jira-feedback3 [ 18976 ]

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Konstantin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: