Ticket #974 (closed defect: fixed)

Opened 15 months ago

Last modified 15 months ago

Type checking when importing fixtures too restrictive since r4249

Reported by: thomas.s Owned by: jwage
Priority: minor Milestone: 0.11.0
Component: Import/Export Version: 0.11.0
Severity: Keywords: inheritance
Cc: Has Test:
Status: Has Patch:

Description

Since r4249 the function _getImportedObject() of Doctrine_Data_Import is throwing an exception when the target object of a relation does not exactly match the specified class in the schema. This breaks my column aggregation inheritance, because now sub classes are not allowed to use the relations of their parents. But that was my intention when i went for inheritance in the first place...

My situation:

- User has Groups

- Expert extends User => Expert has Groups

r4249 is breaking this.

I added a patch and a test case, which can only be used like pseudo code because it's a PHPUnit test case and i'm kind of struggling with the Doctrine test setup. But it should make my intentions clear. I hope somebody can have a look at my proposal and correct me if I am wrong.

I am using Symfony 1.0 with sfDoctrine (0.11 branch).

if ($relation->getClass() !== get_class($relatedRowKeyObject)) {
...
$ php -v
PHP 5.2.5 (cli) (built: Apr 11 2008 12:49:32) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans
$ apachectl -v
Server version: Apache/2.2.8 (Unix)
Server built:   Apr 11 2008 12:35:43
$ sqlite3 -version
3.5.7
$ mysql -V
mysql  Ver 14.12 Distrib 5.0.51, for apple-darwin9.1.0 (i686) using  EditLine wrapper

Attachments

r4249_update_for_subclasses.diff (1.1 KB) - added by thomas.s 15 months ago.
sfGuardGroupTest.php (2.4 KB) - added by thomas.s 15 months ago.
Take this test case as pseudo code: Subclasses should inherit relations.
fixtures.yml (433 bytes) - added by thomas.s 15 months ago.
Simple part of a fixture for the inheritance test case.

Change History

Changed 15 months ago by thomas.s

Changed 15 months ago by thomas.s

Take this test case as pseudo code: Subclasses should inherit relations.

Changed 15 months ago by thomas.s

Simple part of a fixture for the inheritance test case.

Changed 15 months ago by thomas.s

  • keywords inheritance added; fixture import removed
  • owner changed from romanb to jwage
  • component changed from Inheritance to Import/Export

Changed 15 months ago by thomas.s

Inheritance:

Expert:

inheritance:

type: column_aggregation extends: sfGuardUser keyField: type keyValue: 2

extracted from sfGuardUser model:

class sfGuardUser extends BasesfGuardUser? {

public function setTableDefinition() {

parent::setTableDefinition();

// username is not unique because of column aggregation inheritance $this->hasColumn('username', 'string', 128, array('notnull' => true, 'unique' => false)); // generator always creates column with type varchar(255) $this->hasColumn('type', 'integer', 4, array('notnull' => true, 'default' => 0)); $this->index('register_index', array(

'fields' => array('username', 'type'), 'type' => 'unique')

);

}

}

Changed 15 months ago by thomas.s

sorry for that unformatted mess...

Expert:
  inheritance:
    type: column_aggregation
    extends: sfGuardUser
    keyField: type
    keyValue: 2
class sfGuardUser extends BasesfGuardUser
{
    public function setTableDefinition()
    {
        parent::setTableDefinition();
        
        // username is not unique because of column aggregation inheritance
        $this->hasColumn('username', 'string', 128, array('notnull' => true, 'unique' => false));
        // generator always creates column with type varchar(255)
        $this->hasColumn('type', 'integer', 4, array('notnull' => true, 'default' => 0));
        $this->index('register_index', array(
            'fields' => array('username', 'type'),
            'type'   => 'unique')
        );
    }
}

Changed 15 months ago by jwage

  • milestone changed from 0.11.2 to 0.11.0

Changed 15 months ago by jwage

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

fixed by r4283

Changed 15 months ago by jwage

Thanks for the report. This change was made to better error check when relating fixtures in yaml but we forgot to take in to account inheritance. Thanks.

Note: See TracTickets for help on using tickets.