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

        Hide
        Sebastian added a comment -

        Now this is really poor. This trivial bug is known for over a year not but not yet fixed.

        Fixing it would save millions of rainforrest trees because people would not have to rely on hundreds of lazy loading queries per page but start to use the getRelation() method.

        Show
        Sebastian added a comment - Now this is really poor. This trivial bug is known for over a year not but not yet fixed. Fixing it would save millions of rainforrest trees because people would not have to rely on hundreds of lazy loading queries per page but start to use the getRelation() method.
        Hide
        Sebastian added a comment -

        Two years now. :'-(

        Show
        Sebastian added a comment - Two years now. :'-(
        Hide
        Mishal added a comment -

        Another year, and all people are probably on Doctrine2.

        But.... I just pushed your fix #DC-884 to my Doctrine1 fork, if you are interested.

        https://github.com/mishal/doctrine1

        Show
        Mishal added a comment - Another year, and all people are probably on Doctrine2. But.... I just pushed your fix # DC-884 to my Doctrine1 fork, if you are interested. https://github.com/mishal/doctrine1

          People

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

            Dates

            • Created:
              Updated: