I seem to have found the problem on Doctrine's JIRA.
I'ts an unresolved issue: http://www.doctrine-project.org/jira/browse/DC-536

On Nov 16, 8:48 pm, kerdany <[email protected]> wrote:
> Below are two schemas, these are simplified schemas where the problem
> occurs consistently:
>
> In summary:
> - Schema1: Class "Entity" is a base entity, "ChildA"  & "ChildB"
> extend "Entity", and there's a One to Many relation between "ChildB"
> and "Other" (Other has many ChildB).
> - Schema2: Class "Entity" is a base entity, "ChildA"  & "ChildB"
> extend "Entity"
>
> Schema1:
> ########
> detect_relations: false
> Entity:
>   columns:
>     column_x: { type: string(255) }
> ChildA:
>   inheritance: { extends: Entity, type: column_aggregation, keyField:
> type, keyValue: 1 }
>   columns:
>     column_a: { type: string(255) }
> ChildB:
>   inheritance: { extends: Entity, type: column_aggregation, keyField:
> type, keyValue: 2 }
>   columns:
>     column_b: { type: string(255) }
>     other_id: { type: integer, notnull: true }
>   relations:
>     other: { class: Other, local: other_id, foreign: id, foreignType:
> many, type: one }
> Other:
>   columns:
>     column_y: { type: string(255) }
>
> Generated SQL:
> #############
> CREATE TABLE `tbl_entity` (`id` BIGINT AUTO_INCREMENT, `column_x`
> VARCHAR(255), `type` VARCHAR(255), `column_a` VARCHAR(255), `column_b`
> VARCHAR(255), `other_id` BIGINT NOT NULL, PRIMARY KEY(`id`)) ENGINE =
> INNODB;
> CREATE TABLE `tbl_entity` (`id` BIGINT AUTO_INCREMENT, `column_x`
> VARCHAR(255), `type` VARCHAR(255), `column_a` VARCHAR(255), `column_b`
> VARCHAR(255), `other_id` BIGINT NOT NULL, INDEX `other_id_idx`
> (`other_id`), PRIMARY KEY(`id`)) ENGINE = INNODB;
> CREATE TABLE `tbl_entity` (`id` BIGINT AUTO_INCREMENT, `column_x`
> VARCHAR(255), `type` VARCHAR(255), `column_a` VARCHAR(255), `column_b`
> VARCHAR(255), `other_id` BIGINT NOT NULL, INDEX `tbl_entity_type_idx`
> (`type`), PRIMARY KEY(`id`)) ENGINE = INNODB;
> CREATE TABLE `tbl_other` (`id` BIGINT AUTO_INCREMENT, `column_y`
> VARCHAR(255), PRIMARY KEY(`id`)) ENGINE = INNODB;
> ALTER TABLE `tbl_entity` ADD CONSTRAINT
> `tbl_entity_other_id_tbl_other_id` FOREIGN KEY (`other_id`) REFERENCES
> `tbl_other`(`id`);
>
> you'll find that tbl_entity has 3 "CREATE TABLE" statements.
>
> A simpler example goes as follows:
>
> Schema2:
> ########
> detect_relations: false
> Entity:
>   columns:
>     column_x: { type: string(255) }
> ChildA:
>   inheritance: { extends: Entity, type: column_aggregation, keyField:
> type, keyValue: 1 }
>   columns:
>     column_a: { type: string(255) }
> ChildB:
>   inheritance: { extends: Entity, type: column_aggregation, keyField:
> type, keyValue: 2 }
>   columns:
>     column_b: { type: string(255) }
>
> Generated SQL:
> #############
> CREATE TABLE `tbl_entity` (`id` BIGINT AUTO_INCREMENT, `column_x`
> VARCHAR(255), `type` VARCHAR(255), `column_a` VARCHAR(255), `column_b`
> VARCHAR(255), PRIMARY KEY(`id`)) ENGINE = INNODB;
> CREATE TABLE `tbl_entity` (`id` BIGINT AUTO_INCREMENT, `column_x`
> VARCHAR(255), `type` VARCHAR(255), `column_a` VARCHAR(255), `column_b`
> VARCHAR(255), INDEX `tbl_entity_type_idx` (`type`), PRIMARY KEY(`id`))
> ENGINE = INNODB;
>
> you'll find that tbl_entity has 2 "CREATE TABLE" statements.
>
> On Nov 16, 1:19 pm, Alexandre Salomé <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > Could you show us your schema ? Can be because of a misconfigured schema.
>
> > 2010/11/15 Hany El-Kerdany<[email protected]>
>
> > > Dear All,
>
> > > I'm using inheritance in my Doctrine model (column_aggregation).
> > > When I generate the SQL from Models (using symfony's doctrine:generate
> > > --all), I find that there's a redundant CREATE TABLE statement (all for 
> > > the
> > > same table, since I'm using column_aggregation)..
> > > This seems like a bug to me, and running the generated SQL on a MySQL
> > > client like (Query Analyzer) generates an error when attempting to run the
> > > second CREATE TABLE statement.
>
> > > Is there a workaround for this? Should I perhaps create the SQL myself?
>
> > > --
> > > If you want to report a vulnerability issue on symfony, please send it to
> > > security at symfony-project.com
>
> > > You received this message because you are subscribed to the Google
> > > Groups "symfony users" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<symfony-users%2bunsubscr...@goog
> > >  legroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/symfony-users?hl=en
>
> > --
> > Alexandre Saloméhttp://alexandre-salome.fr

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to