Ticket #627 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

InheritanceMap isn't generated from schema.yml

Reported by: adrive Owned by: somebody
Priority: major Milestone: 2.0.0 (OLD)
Component: Other Version:
Severity: Keywords:
Cc: Has Test:
Status: Has Patch:

Description

I updated to latest sfDoctrine branches/1.0 (rev. 6227) with Doctrine branches/1.0 (rev. 3273).

After running symfony doctrine-build-model i found, that inheritance wasn't generated properly.

I use schema:

Entity:
  tableName: entity
  columns:
    title:
      type: string
      size: 20
    type:
      type: integer
      
User:
  inheritance:
    extends: Entity
    keyField: type
    keyValue: 1

User was properly extended by Entity, but InheritanceMap? in setUp method wasn't generated. Here are generated classes:

abstract class BaseEntity extends sfDoctrineRecord
{

  public function setTableDefinition()
  {
    $this->setTableName('entity');
    $this->hasColumn('title', 'string', 20, array (
));
    $this->hasColumn('type', 'integer', null, array (
));
  }
}


abstract class BaseUser extends Entity
{

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

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

}

In previous sfDoctrine I've used (sfDoctrine 6142, Doctrine 3142) was InheritanceMap? generated properly in setUp method of child class.

abstract class BaseUser extends Entity
{

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

  public function setUp()
  {
    parent::setUp();
    $this->setInheritanceMap(array('type' => 1));
  }
}

Change History

Changed 2 years ago by phuson

  • milestone set to beta2

Changed 2 years ago by jackbravo

The inheritanceMap method is deprecated I believe. To define that kind of inheritance, now the parent class defines a setSubclasses method.

 http://doctrine.pengus.net/index.php/documentation/manual?chapter=relations#inheritance

So maybe a new yaml syntax is needed.

Changed 2 years ago by romanb

  • milestone changed from beta2 to beta3

Changed 2 years ago by adrive

Use of setSubclasses causes Segmentation faults in symfony + sfDoctrine + Doctrine.

Also, there should be some situations, where you will need to define it by yourself in child class, not in the parent class. For example: you have base model in your base plugin, and you will need to create your own type based on the parent model, you couldn't change...

Changed 2 years ago by anonymous

  • milestone beta3 deleted

Milestone beta3 deleted

Changed 2 years ago by jwage

  • milestone set to 1.0

Changed 2 years ago by jwage

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

(In [3889]) fixes #627 #791 This also fixes an issue where the class tables do not extend the correct class when dealing with inheritance. Also new tests to cover this functionality.

Changed 2 years ago by anonymous

  • milestone 1.0 deleted

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.