Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-868

ORM:Schema-tool:create failure -- the result depends on xml files enumeration order of RecursiveDirectoryIterator in context of SINGLE_TABLE inherantence

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA4
    • Fix Version/s: 2.0-RC1
    • Component/s: Tools
    • Security Level: All
    • Labels:
      None
    • Environment:
      Windows or Linux, PHP-5.3.3

      Description

      = Relevant configuration: =
      resources.doctrine.driver.class = Doctrine\ORM\Mapping\Driver\XmlDriver
      resources.doctrine.driver.dir = APPLICATION_PATH "/../library/Droop/Model/Xml"
      resources.doctrine.cache.class = Doctrine\Common\Cache\ArrayCache
      resources.doctrine.conn.driver = pdo_mysql

      = Models hierarchy =
      class Sysbase {}
      class Drooplet extends Sysbase {}
      class Menu extends Sysbase {}

      = Xml driver =
      attached

      = Error =
      While using command line to generate schema [php doctrine.php orm:schema-tool:create --dump-sql], it reports error "The table with name 'system' already exists." on windows however not on linux.

      It is because the ClassMetaFactory.php depends on the sequence of result returned by getAllClassNames(). In this scenario, it's in descending order on linux and ascending on windows.
      124 foreach ($this->driver->getAllClassNames() as $className)

      { 125 $metadata[] = $this->getMetadataFor($className); 126 }

      127
      128 return $metadata;
      This order populates to SchemaTool::getSchemaFromMetadata(); If the base model is processed before it's descendants, everything is OK. Otherwise, it will complain about the table already exists.

      = Fix =
      ClassMetaFactory.php
      128 return $this->loadedMetadata;

      1. Droop.Model.Drooplet.dcm.xml
        0.4 kB
        Jim Chen
      2. Droop.Model.Menu.dcm.xml
        0.4 kB
        Jim Chen
      3. Droop.Model.Sysbase.dcm.xml
        1 kB
        Jim Chen

        Activity

        Hide
        Benjamin Eberlei added a comment -

        By what means is that a valid fix? Doesnt that just give another random order that happens to work for your cases now?

        Show
        Benjamin Eberlei added a comment - By what means is that a valid fix? Doesnt that just give another random order that happens to work for your cases now?
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Jim Chen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: