[DC-1015] bindComponent not called before inherited classes base definitions Created: 04/Jul/11  Updated: 04/Jul/11

Status: Open
Project: Doctrine 1
Component/s: Inheritance, Schema Files
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Adrian Nowicki Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

symfony 1.4



 Description   

If I define a base model:

Entity:
connection: other
columns:
name: {}
size: {}

and inherited model:

Box:
inheritance:
extends: Entity
type: column_aggregation

Then file with base definition of Box does not contain bindComponent sentence to bind Box model with connection specified for Entity model.






[DC-924] type mismatch for keyfield in column aggregation Created: 11/Nov/10  Updated: 11/Nov/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance
Affects Version/s: 1.2.3
Fix Version/s: 1.2.3

Type: Bug Priority: Major
Reporter: Arnaud Morvan Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None
Environment:

PostgreSQL



 Description   

This is the doc exemple on column aggregation inheritance :

Entity:
columns:
username: string(20)
password: string(16)
created_at: timestamp
updated_at: timestamp

User:
inheritance:
extends: Entity
type: column_aggregation
keyField: type
keyValue: 1

Group:
inheritance:
extends: Entity
type: column_aggregation
keyField: type
keyValue: 2

But the keyField (type) is created as VARCHAR(255) so PostgreSQL return an error on applying inheritance condition :

SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer
LINE 1: ...D s.application = 'frontend' AND s.lft = 1) AND (s.type = 2)
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

I found this with symfony sfFilebasePlugin on sfFilebase:create-root task.






[DC-778] Aggregate column becomes NULL when using TableClass->create(array(...)) Created: 08/Jul/10  Updated: 01/Sep/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Dennis Verspuij Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I use aggregate column inheritance, say B extends A, and create a new record instance of B using BTable->create(array(...values...)). But due to changeset [7618] this fails to set the aggregate column value to the value assigned for B, it becomes NULL.



 Comments   
Comment by Jonathan H. Wage [ 01/Sep/10 ]

Can you provide some more information and/or a test case?





[DC-619] preHydrate/postHydrate events do not use proper sub-class component Created: 06/Apr/10  Updated: 14/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance, Record
Affects Version/s: 1.2.0, 1.2.1, 1.2.2
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Matt Lehner Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None
Environment:

PHP 5.2.11 (cli), Doctrine 1.2 (Revision: 7537)



 Description   

I am trying to use preHydrate/postHydrate with my models that use inheritance. The problem is that when using the parent table is used to query the records, the preHydrate/postHydrate events are passed to the parent record class instead of the proper sub-class for the current record.

Using the example schema below, if I do a findAll() on the Person table and it contained two Student records and one Professor record... preHydrate would get called on Person instead of Student and Professor. This also applies for any listeners that are registered on Student/Professor and not Person.

Person:
columns:
name:

{ type: string(50) }

Student:
inheritance:
extends: Person
type: column_aggregation
keyField: type
keyType: 1

Professor:
inheritance:
extends: Person
type: column_aggregation
keyField: type
keyValue: 2






[DC-614] Separate the properties of the parent and the children Created: 02/Apr/10  Updated: 02/Apr/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Task Priority: Major
Reporter: Thomas Tourlourat - Armetiz Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I want to talk about the inheritance, simple type and columns_aggregation.

Here an example of parent classes and two sub-classes : http://pastebin.com/5qJKtgp1
Here the generated models classes : http://pastebin.com/j2PmT7sd

To sum up : The parent class is Show, and the sub-classes are Video and Playlist.

  • A Show have a title.
  • A Video have a filename.
  • A Playlist have a user.

The problem that appear with the generated models, Is that the following code is working.
$playlist = Doctrine_Core::getTable ("Model_Playlist")->find (3);
$playlist->filename;

Or, the POO concept want that the filename property doesn't exist/available on a Playlist object. And Doctrine should throw an Exception ! Or, It is not the case.

The solution is to move the generated code of the sub-classes into there own classes.
Here the complete solution : http://pastebin.com/LzTG10P7

The problem with the one-to-one or many-to-many relationship is still the same.

The solution is more POO compliant.






[DC-536] Duplicate CREATE TABLE entries in schema.sql when using column_inheritance Created: 02/Mar/10  Updated: 18/Nov/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: webPragmatist Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 3
Labels: None
Environment:

MySQL 5 / PHP 5.3.1 / Symfony 1.4.3 (branch) / Doctrine 1.2.1 / Mac OSX


Attachments: File BaseInherited.class.php     File BaseInheriter.class.php     File kerdany_10-11-18-08-30.sql     File kerdany_10-11-18-08-30.yml     Text File sandbox-console.txt     File schema.sql    

 Description   

When creating a model involving column_inheritance the CREATE TABLE statement gets duplicated.

The second CREATE TABLE include an index for the keyField.

Test doctrine generated models and generated schema.sql attached.



 Comments   
Comment by webPragmatist [ 02/Mar/10 ]

It seems this issue is related to using array_unique() and databases which doctrine creates index along with the CREATE TABLE statement.

This does not occur on sqlite as shown above in the console-log.txt (this db uses the CREATE INDEX statement).

Comment by Svetoslav Shterev [ 02/Mar/10 ]

Yes, it seems SQL CREATE TABLE statements are generated for each of the children as well, but with sqlite, array_unique() filters out the ones that are "extra".
But the MySQL statements all differ(due to indexes, I don't know if other things can cause them to differ as well), and as such all are left.

Comment by Tom Boutell [ 07/May/10 ]

We're seeing this issue too. doctrine:build --all --and-load works fine, but doctrine:build-sql generates duplicate CREATE TABLE statements. Our in-house workflow is the former, so the latter came as a surprise. Is there any sign of progress on this one?

Comment by Sebastian Schulze [ 07/Jul/10 ]

This looks like a Duplicate of DC-123.

Comment by Hany el-Kerdany [ 18/Nov/10 ]

A little addition to the symptoms of this problem.

If the one of the child classes has a foreign key to another entity, another Third Create table SQL will be created, which contains the an index on the foreign key column.

In other words, it seems that an additional create table statement is created for each automatically created index.

An illustration is in the attached yml and sql schema:
kerdany_10-11-18-08-30.yml
kerdany_10-11-18-08-30.sql

Tom Boutell: doctrine:build --all generates the problem with me!





[DC-607] Doctrine concrete inheritance link between tables Created: 30/Mar/10  Updated: 21/Jul/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Julien Chiron Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 1
Labels: None
Environment:

Symfony 1.4.3, php5.3.0 (snow leopard version)



 Description   

Hi,

I pointed out a strange problem:
I have two tables that are linked with a one to many relation ship.
Each table has some concrete inherited tables.
Here is the schema:

Batch:
  columns:
    code: string
    is_pure: boolean

Flask:
  columns:
    batch_id: integer
    code: string
    quantity: integer
  relations:
    Batch:
      local: batch_id
      foreign: id
      foreignType: many
    
ProducedBatch:
  inheritance:
    type: concrete
    extends: Batch
  columns:
    production_date: date
    
BoughtBatch:
  inheritance:
    type: concrete
    extends: Batch
  columns:
    supplier: string
    
ProducedFlask:
  inheritance:
    type: concrete
    extends: Flask
  columns:
    weight: integer
    
BoughtFlask:
  inheritance:
    type: concrete
    extends: Flask
  columns:
    price: integer

The problem occurs when I try to populate the database.
Here is the data:

ProducedBatch:
  B1:
    code: Batch1

ProducedFlask:
  F1:
    Batch: B1
    code: Flask1

When loading fixtures, I get a

Invalid row key specified: (batch) B1, referred to in (produced_flask) F1

In fact, Doctrine doesn't take into account the primary key inherited from Flask table.
The mapping should be done between parent and child tables.

The only solution to solve this is to set a relationship between each couple of sub-table (ProducedFlask -> ProducedBatch and BoughtFlask -> BoughtFlask).



 Comments   
Comment by TD [ 21/Jul/10 ]

It is very strange that the doctrine inheritance system don't inherite all the relationship of the mother-table on all sub-table. I think that it will be a very good improvement to fix this problem.

For example if you are this model :

Unable to find source-code formatter for language: yml. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
 
motherTable:
  columns:
     code: string
     relationTable_id: integer
  relation:
     relationTableRelation:
            local: relationTable_id
            foreign: id
            type: one     

subTable:
    inheritance:
        type: concrete
    colums:
        name: string

relationTable:
    columns:
        code: integer
    relations:
        motherTableRelation:
            local: id
            foreign: relationTable_id
            type: many

In this example, the relationTableRelation will be inherited, it is good but the other side of the relation in relation table will always go on motherTable and not on subTable, but motherTable is always empty, moreover subTable don't share its ID with motherTable, so this side of the relationship is unusefull because we can find subTable element in relation with a relationTable element.

It will be good to find a solution to this issue





[DC-418] Inherited models creating NOT NULL restrictions on their parents Created: 11/Jan/10  Updated: 11/Jan/10

Status: Open
Project: Doctrine 1
Component/s: Attributes, Inheritance, Record, Schema Files
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: luke scott Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Linux skywalker-9 2.6.31-17-generic #54-Ubuntu SMP Thu Dec 10 17:01:44 UTC 2009 x86_64 GNU/Linux


Attachments: File sample.yaml    

 Description   

to reproduce, create the yaml included in sample.yaml (Note the not-null columns in each subclass)

if you try to save an OnlineProduct without setting copyright_year, or if you create a print_product without setting website_branding_id, then you will get a not null error.
Inherited tables should be able to set their own NOT NULL columns without affecting other tables in the inheritance tree (should be handled in the preSave() method? or is there another mechanism?)



 Comments   
Comment by luke scott [ 11/Jan/10 ]

YAML format was destroyed during copy & paste!
I'm attaching the sample yaml, instead of including it in the description





[DC-464] [Inheritance] Couldn't save record with inheritance by a relationship if the record has no column modified (solution proposed) Created: 29/Jan/10  Updated: 09/Jun/10

Status: Open
Project: Doctrine 1
Component/s: Inheritance
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Colin Darie Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File DC464TestCase.php     Text File Record.php.patch    

 Description   

Please consider the following TestCase

Inheritance with no property setted, saved by relationship
class Doctrine_Ticket_DC464_TestCase extends Doctrine_UnitTestCase
{
    public function prepareTables()
    {
        $this->tables[] = 'Ticket_DC464_Entity';
        $this->tables[] = 'Ticket_DC464_Article';
        $this->tables[] = 'Ticket_DC464_User';
        $this->tables[] = 'Ticket_DC464_Group';
        parent::prepareTables();
    }

    public function testTest()
    {
        $User = new Ticket_DC464_User();

        $Article = new Ticket_DC464_Article();
        $Article->title = 'my first article';
        $Article->Author = $User;

        $Article->save();

        $UserFetched = Doctrine::getTable('Ticket_DC464_User')->find(1);
        $this->assertTrue($UserFetched instanceof Ticket_DC464_User);
       //$this->assertEqual($UserFetched->type, 1);


    }
}



class Ticket_DC464_Entity extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('id', 'integer', 11, array('autoincrement' => true, 'primary' => true));
        $this->hasColumn('facultative_field', 'string', 255);
        $this->hasColumn('type', 'string', 255);

        $this->setSubClasses(array(
             'Ticket_DC464_User' =>  array('type' => 1),
             'Ticket_DC464_Group' => array('type' => 2),
        ));

        $this->option('type', 'InnoDB');
    }

    public function setUp()
    {
    }
}

class Ticket_DC464_User extends Ticket_DC464_Entity { }
class Ticket_DC464_Group extends Ticket_DC464_Entity { }

class Ticket_DC464_Article extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('id', 'integer', 11, array('autoincrement' => true, 'primary' => true));
        $this->hasColumn('title', 'string', 30);
        $this->hasColumn('author_id', 'integer', 11);

        $this->option('type', 'InnoDB');
    }

    public function setUp()
    {
        $this->hasOne('Ticket_DC464_User as Author', array(
             'local' => 'author_id',
             'foreign' => 'id'));
    }
}

Notice that in the test, the $User instance has no property setted (in fact in this test, the "useless_field" in the model is... useless).

This test fails (the $User object is not saved) because the method UnitOfWork->saveRelatedLocalKeys() - called in saveGraph(), itself called by $Article->save() - returns false because no column has been modified (line 395).

To fix this, the Record->assignInheritanceValues() should be executed in top of isModified(), or for each related object in UnitOfWork->saveRelatedLocalKeys() (and probably UnitOfWork->saveRelatedForeignKeys() too).

I've attached the test.



 Comments   
Comment by Colin Darie [ 30/Jan/10 ]

Fix test with the right prefixes

Comment by Jonathan H. Wage [ 15/Mar/10 ]

Do you have a patch for the issue too?

Comment by Colin Darie [ 16/Mar/10 ]

Hi,

no I doesn't have a patch for this, because I was not sure what the best way to solve this.
However, patching the isModified() method is maybe the safest way, with a simple $this->assignInheritanceValues(); at top (around line 2100).

Comment by Jonathan H. Wage [ 08/Jun/10 ]

Can you provide a patch for that change then so I can see it and test it? Thanks, Jon

Comment by Colin Darie [ 09/Jun/10 ]

I've attached the patch.

Once again, this patch fix the issue but there is maybe a better way to fix it to avoid the assignInheritanceValues() at each time.

Thanks.





Generated at Thu Apr 24 04:09:30 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.