Uploaded image for project: 'Doctrine 1'
  1. Doctrine 1
  2. DC-536

Duplicate CREATE TABLE entries in schema.sql when using column_inheritance

    Details

    • Type: Bug
    • Status: Open
    • Priority: 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

        webpragmatist webPragmatist created issue -
        Hide
        webpragmatist 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 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).
        webpragmatist webPragmatist made changes -
        Field Original Value New Value
        Attachment sandbox-console.txt [ 10414 ]
        Hide
        sacho 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
        sacho 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.
        romanb Roman S. Borschel made changes -
        Assignee Roman S. Borschel [ romanb ] Jonathan H. Wage [ jwage ]
        Hide
        boutell 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
        boutell 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
        bascht Sebastian Schulze added a comment -

        This looks like a Duplicate of DC-123.

        Show
        bascht Sebastian Schulze added a comment - This looks like a Duplicate of DC-123 .
        kerdany Hany el-Kerdany made changes -
        Attachment kerdany_10-11-18-08-30.yml [ 10870 ]
        Attachment kerdany_10-11-18-08-30.sql [ 10871 ]
        Hide
        kerdany 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
        kerdany 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!
        kerdany Hany el-Kerdany made changes -
        Comment [ illustrating the duplicate generation of CREATE TABLE statements, one extra statement for each automatically created index. ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={expand=changesets[0:20].revisions[0:29],reviews, query=DC-536}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

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

            Dates

            • Created:
              Updated: