Development

#10041 (Inheritance and nested save() call : "Unknown record property / related component")

You must first sign up to be able to contribute.

Ticket #10041 (new defect)

Opened 1 year ago

Last modified 1 year ago

Inheritance and nested save() call : "Unknown record property / related component"

Reported by: tmaindron Assigned to: Jonathan.Wage
Priority: minor Milestone:
Component: sfDoctrinePlugin Version: 1.4.16
Keywords: Cc:
Qualification: Unreviewed

Description

I have a schema where I extend sfGuardGroup to bind it to a "Company" table.

Here's the part of the schema:

Group:
  inheritance:
    extends: sfGuardGroup
    type: simple
  columns:
    company_id: integer
  relations:
    Company:
      class: Company
      local: company_id
      foreignAlias: Group
      foreignType: one
      type: one

Now in my company object, on the save call, I try this:

  public function save(Doctrine_Connection $conn = null)
  {
      parent::save($conn);

      $group = $this->getGroup();

      // Mapped group update

      $mappingPrefix = uniquid();

      if (!$group->exists())
      {
        $group = new Group();
        $group->setName($mappingPrefix . $this->getName());
        $group->setCompanyId($this->getId());
        $group->save();
      }
      else
      {
        $group->setName($mappingPrefix . $this->getName());
        $group->save();
      }
  }

I end up with the error in the title:

Unknown record property / related component "name" on "Group"

If I add this to Company:

  public function getGroup(){
    $result = GroupTable::getInstance()->createQuery('q')
      ->where('company_id = ?', $this->getId())
      ->fetchOne();

    return $result ? $result : new Group();
  }

Everything works again!

Change History

06/25/12 15:24:04 changed by tmaindron

  • version changed from 1.4.10 to 1.4.16.

Woops, wrong version of Symfony!