Ticket #1180 (closed defect: fixed)

Opened 12 months ago

Last modified 10 months ago

Second Level inheritance is not getting the correct fields

Reported by: isleshocky77 Owned by: romanb
Priority: major Milestone:
Component: Inheritance Version: 0.11.0
Severity: Keywords: inheritance
Cc: isleshocky77 Has Test: no
Status: Pending Core Response Has Patch: no

Description

Data structure

  • Person [id, name]
  • Student extends Person [major, year]
  • Alumna extends Student [year_graduated]
$alumnus = Doctrine::getTable('Alumna')->find(1);
echo $alumnus['year_is_graduate'];

Fails with:

Unknown record property / related component "is_graduate" on "Alumna"

Change History

Changed 12 months ago by isleshocky77

It looks like inheritance is being done wrong for column aggregation from the class generation from yaml. It's putting all the columns in the parent class rather than in the sub-classes

---
Person:
  actAs:
    Timestampable: ~
    Sluggable:
      name: identifier
      fields: [name]
  columns:
    id:
      type: integer(10)
      primary: true
      autoincrement: true
    name:
      type: string(255)
    body:
      type: string
    statement:
      type: string
    personal_url:
      type: string(255)
    image_filename:
      type: string(255)
    thumbnail_filename:
      type: string(255)
    email:
      type: string(255)
    bullets:
      type: string(255)
    image_group_id:
      type: integer(10)
  relations:
    ImageGroup:
      class: ImageGroup
      foreignAlias: Person
      foreignType: one
    PersonGroups:
      class: PersonGroup
      foreignAlias: Persons
      refClass: PersonGroupPerson
---
Student:
  inheritance:
    extends: Person
    type: column_aggregation
    keyField: class
    keyValue: Student
  columns:
    location:
      type: string(255)
    major:
      type: string(255)
    year:
      type: string(255)
---
Alumna:
  inheritance:
    extends: Student
    type: column_aggregation
    keyField: class
    keyValue: Alumna
  columns:
    is_graduate:
      type: boolean
      default: false
    graduated:
      type: string(255)
    employment:
      type: string(255)
    department:
      type: string(255)
abstract class BasePerson extends sfDoctrineRecord
{

  public function setTableDefinition()
  {
    $this->setTableName('person');
    $this->hasColumn('id', 'integer', 10, array('type' => 'integer', 'primary' => true, 'autoincrement' => true, 'length' => '10'));
    $this->hasColumn('name', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('body', 'string', null, array('type' => 'string'));
    $this->hasColumn('statement', 'string', null, array('type' => 'string'));
    $this->hasColumn('personal_url', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('image_filename', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('thumbnail_filename', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('email', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('bullets', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('image_group_id', 'integer', 10, array('type' => 'integer', 'length' => '10'));
    $this->hasColumn('class', 'string', 255, array('type' => 'string', 'length' => 255));
    $this->hasColumn('location', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('major', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('year', 'string', 255, array('type' => 'string', 'length' => '255'));
    $this->hasColumn('is_retired', 'boolean', null, array('type' => 'boolean'));
    $this->hasColumn('department', 'string', 255, array('type' => 'string', 'length' => '255'));

    $this->setSubClasses(array('Alumna' => array('class' => 'Alumna'), 'GuestSpeaker' => array('class' => 'GuestSpeaker'), 'Student' => array('class' => 'Student'), 'Teacher' => array('class' => 'Teacher')));
  }

  public function setUp()
  {
    parent::setUp();
    $this->hasOne('ImageGroup', array('local' => 'image_group_id',
                                      'foreign' => 'id'));

    $this->hasMany('PersonGroup as PersonGroups', array('refClass' => 'PersonGroupPerson',
                                                        'local' => 'person_id',
                                                        'foreign' => 'person_group_id'));

    $this->hasMany('PersonGroupPerson as PersonGroupPersons', array('local' => 'id',
                                                                    'foreign' => 'person_id'));

    $timestampable0 = new Doctrine_Template_Timestampable();
    $sluggable0 = new Doctrine_Template_Sluggable(array('name' => 'identifier', 'fields' => array(0 => 'name')));
    $this->actAs($timestampable0);
    $this->actAs($sluggable0);
  }

}
abstract class BaseStudent extends Person
{


  public function setUp()
  {
    parent::setUp();
  }

}
abstract class BaseAlumna extends Student
{


  public function setUp()
  {
    parent::setUp();
  }

}



Changed 12 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [4589]) fixes #1180

Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.