Doctrine 1
  1. Doctrine 1
  2. DC-359

concrete inheritance doesn't create all relations

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.0, 1.2.1
    • Fix Version/s: None
    • Component/s: Schema Files
    • Labels:
      None
    • Environment:

      Description

      This is the YML schema

      Entity:
        actAs:
          Timestampable:
        columns:
          id:
            type: integer(11)
            primary: true
            autoincrement: true
          name: string(50)
        relations:
          DynamicFields:
            class: DynamicField
            local: id
            foreign: dynamic_field_id
            refClass: EntityDynamicFields
      
      DynamicField:
        actAs:
          I18n:
            fields: [name_xml]
        columns:
          id:
            type: integer(11)
            primary: true
            autoincrement: true
          name_xml: 
            type: string(50)
            notnull: true
        relations:
          Entities:
            class: Entity
            local: dynamic_field_id
            foreign: id
            refClass: EntityDynamicFields
      
      EntityDynamicFields:
        actAs:
          I18n:
            fields: [value_xml]
        columns:
          id:
            type: integer(11)
            primary: true
          dynamic_field_id:
            type: integer(11)
            primary: true
          value_xml: string(250)
      
      Airline:
        inheritance:
          extends: Entity
          type: concrete
      
      Bank:
        inheritance:
          extends: Entity
          type: concrete
      
      Client:
        inheritance:
          extends: Entity
          type: concrete
      
      Employe:
        inheritance:
          extends: Entity
          type: concrete
      
      Host:
        inheritance:
          extends: Entity
          type: concrete
      
      Partner:
        inheritance:
          extends: Entity
          type: concrete
      
      Person:
        inheritance:
          extends: Entity
          type: concrete
      
      Supplier:
        inheritance:
          extends: Entity
          type: concrete
      
      

      I run the commands

      ./doctrine build-all
      

      and

      ./doctrine rebuild-db
      

      The problem is when I verify if the foreign keys are created, but
      these were only created for the "client" and "employee" models, to
      "host" does not create the relationship in the MySQL, but if I rename
      "host" with a name like "Ent", the relationship is established, or if I rename
      the parent model "Entity" to "Zzzzz", all relations are created.

      I did several tests, and the only way that the relation is created, is
      that the model name, is alphabetically sorted before the parent model name.

      This is a part of the dump of MySQL

      ALTER TABLE `entity_dynamic_fields`
        ADD CONSTRAINT `entity_dynamic_fields_dynamic_field_id_dynamic_field_id` FOREIGN KEY (`dynamic_field_id`) REFERENCES `dynamic_field` (`id`),
        ADD CONSTRAINT `entity_dynamic_fields_id_airline_id` FOREIGN KEY (`id`) REFERENCES `airline` (`id`),
        ADD CONSTRAINT `entity_dynamic_fields_id_bank_id` FOREIGN KEY (`id`) REFERENCES `bank` (`id`),
        ADD CONSTRAINT `entity_dynamic_fields_id_client_id` FOREIGN KEY (`id`) REFERENCES `client` (`id`),
        ADD CONSTRAINT `entity_dynamic_fields_id_employe_id` FOREIGN KEY (`id`) REFERENCES `employe` (`id`),
        ADD CONSTRAINT `entity_dynamic_fields_id_entity_id` FOREIGN KEY (`id`) REFERENCES `entity` (`id`);
      

      The other foreign keys are missed

      you can view the diagram EER created with reverse engineering of MySQL Workbench

      1. fix-dc-359.diff
        1 kB
        Juan Vega
      1. Picture 1.png
        92 kB

        Activity

        Hide
        Juan Vega added a comment -

        I know where is the problem, in Doctrine_Core::loadModels the list of models returned are alphabetically sorted, if I can rearrange the array by inheritance, the foreign keys for the models ('host' 'partner' 'person' 'supplier') are created.

        more explicity:

        I have this

        Array
        (
            [0] => Airline
            [1] => Bank
            [2] => Client
            [3] => DynamicField
            [4] => Employe
            [5] => Entity
            [6] => EntityDynamicFields
            [7] => Host
            [8] => Partner
            [9] => Person
            [10] => Supplier
        )
        

        I need this

        Array
        (
            [0] => Entity
            [1] => Airline
            [2] => Bank
            [3] => Client
            [4] => Employe
            [5] => Host
            [6] => Partner
            [7] => Person
            [8] => Supplier
            [9] => DynamicField
            [10] => EntityDynamicFields
        )
        
        Show
        Juan Vega added a comment - I know where is the problem, in Doctrine_Core::loadModels the list of models returned are alphabetically sorted, if I can rearrange the array by inheritance, the foreign keys for the models ('host' 'partner' 'person' 'supplier') are created. more explicity: I have this Array ( [0] => Airline [1] => Bank [2] => Client [3] => DynamicField [4] => Employe [5] => Entity [6] => EntityDynamicFields [7] => Host [8] => Partner [9] => Person [10] => Supplier ) I need this Array ( [0] => Entity [1] => Airline [2] => Bank [3] => Client [4] => Employe [5] => Host [6] => Partner [7] => Person [8] => Supplier [9] => DynamicField [10] => EntityDynamicFields )
        Hide
        Juan Vega added a comment -

        ok, this is my patch to rearrange the models loaded, this array puts the child models before the parents

        Show
        Juan Vega added a comment - ok, this is my patch to rearrange the models loaded, this array puts the child models before the parents

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Juan Vega
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: