[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!

Generated at Sat Oct 25 07:47:55 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.