Doctrine 1
  1. Doctrine 1
  2. DC-884

Doctrine_Collection::loadRelated uses getLocal instead of getLocalFieldName

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None
    • Environment:
      Windows

      Description

      Having a camelcase fieldname with a lowercase column name causes loadRelated of doctrine collection to throw an unknown property error, fix:

      Change

      $rel     = $this->_table->getRelation($name);
      
              if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) {
                  foreach ($this->data as $record) {
                      $list[] = $record[$rel->getLocal()];
                  }
              }
      

      to:

      $rel     = $this->_table->getRelation($name);
      
              if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) {
                  foreach ($this->data as $record) {
                      $list[] = $record[$rel->getLocalFieldName()];
                  }
              }
      
      public function populateRelated($name, Doctrine_Collection $coll)
          {
              $rel     = $this->_table->getRelation($name);
              $table   = $rel->getTable();
              $foreign = $rel->getForeign();
              $local   = $rel->getLocal();
      

      to

      public function populateRelated($name, Doctrine_Collection $coll)
          {
              $rel     = $this->_table->getRelation($name);
              $table   = $rel->getTable();
              $foreign = $rel->getForeignFieldName();
              $local   = $rel->getLocalFieldName();
      

        Activity

        Jason Brumwell created issue -
        Jason Brumwell made changes -
        Field Original Value New Value
        Description Having a camelcase fieldname with a lowercase column name causes loadRelated of doctrine collection to throw an unknown property error, fix:

        Change
        {code}
        $rel = $this->_table->getRelation($name);

                if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) {
                    foreach ($this->data as $record) {
                        $list[] = $record[$rel->getLocal()];
                    }
                }
        {code}

        to:

        {code}
        $rel = $this->_table->getRelation($name);

                if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) {
                    foreach ($this->data as $record) {
                        $list[] = $record[$rel->getLocalFieldName()];
                    }
                }
        {code}
        Having a camelcase fieldname with a lowercase column name causes loadRelated of doctrine collection to throw an unknown property error, fix:

        Change
        {code}
        $rel = $this->_table->getRelation($name);

                if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) {
                    foreach ($this->data as $record) {
                        $list[] = $record[$rel->getLocal()];
                    }
                }
        {code}

        to:

        {code}
        $rel = $this->_table->getRelation($name);

                if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) {
                    foreach ($this->data as $record) {
                        $list[] = $record[$rel->getLocalFieldName()];
                    }
                }
        {code}

        {code}
        public function populateRelated($name, Doctrine_Collection $coll)
            {
                $rel = $this->_table->getRelation($name);
                $table = $rel->getTable();
                $foreign = $rel->getForeign();
                $local = $rel->getLocal();
        {code}

        to
        {code}
        public function populateRelated($name, Doctrine_Collection $coll)
            {
                $rel = $this->_table->getRelation($name);
                $table = $rel->getTable();
                $foreign = $rel->getForeignFieldName();
                $local = $rel->getLocalFieldName();
        {code}

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Jason Brumwell
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: