Doctrine 1
  1. Doctrine 1
  2. DC-536

Duplicate CREATE TABLE entries in schema.sql when using column_inheritance

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: Inheritance
    • Labels:
      None
    • Environment:
      MySQL 5 / PHP 5.3.1 / Symfony 1.4.3 (branch) / Doctrine 1.2.1 / Mac OSX

      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.

      1. BaseInherited.class.php
        0.4 kB
        webPragmatist
      2. BaseInheriter.class.php
        1 kB
        webPragmatist
      3. kerdany_10-11-18-08-30.sql
        0.6 kB
        Hany el-Kerdany
      4. kerdany_10-11-18-08-30.yml
        0.4 kB
        Hany el-Kerdany
      5. sandbox-console.txt
        1 kB
        webPragmatist
      6. schema.sql
        0.4 kB
        webPragmatist

        Activity

        Hide
        webPragmatist added a comment - - edited

        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).

        Show
        webPragmatist added a comment - - edited 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).
        Hide
        Svetoslav Shterev added a comment -

        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.

        Show
        Svetoslav Shterev added a comment - 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.
        Hide
        Tom Boutell added a comment -

        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?

        Show
        Tom Boutell added a comment - 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?
        Hide
        Sebastian Schulze added a comment -

        This looks like a Duplicate of DC-123.

        Show
        Sebastian Schulze added a comment - This looks like a Duplicate of DC-123 .
        Hide
        Hany el-Kerdany added a comment -

        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!

        Show
        Hany el-Kerdany added a comment - 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!

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            webPragmatist
          • Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: