Doctrine 1
  1. Doctrine 1
  2. DC-607

Doctrine concrete inheritance link between tables

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Inheritance
    • Labels:
      None
    • Environment:
      Symfony 1.4.3, php5.3.0 (snow leopard version)

      Description

      Hi,

      I pointed out a strange problem:
      I have two tables that are linked with a one to many relation ship.
      Each table has some concrete inherited tables.
      Here is the schema:

      Batch:
        columns:
          code: string
          is_pure: boolean
      
      Flask:
        columns:
          batch_id: integer
          code: string
          quantity: integer
        relations:
          Batch:
            local: batch_id
            foreign: id
            foreignType: many
          
      ProducedBatch:
        inheritance:
          type: concrete
          extends: Batch
        columns:
          production_date: date
          
      BoughtBatch:
        inheritance:
          type: concrete
          extends: Batch
        columns:
          supplier: string
          
      ProducedFlask:
        inheritance:
          type: concrete
          extends: Flask
        columns:
          weight: integer
          
      BoughtFlask:
        inheritance:
          type: concrete
          extends: Flask
        columns:
          price: integer
      

      The problem occurs when I try to populate the database.
      Here is the data:

      ProducedBatch:
        B1:
          code: Batch1
      
      ProducedFlask:
        F1:
          Batch: B1
          code: Flask1
      

      When loading fixtures, I get a

      Invalid row key specified: (batch) B1, referred to in (produced_flask) F1

      In fact, Doctrine doesn't take into account the primary key inherited from Flask table.
      The mapping should be done between parent and child tables.

      The only solution to solve this is to set a relationship between each couple of sub-table (ProducedFlask -> ProducedBatch and BoughtFlask -> BoughtFlask).

        Activity

        Hide
        TD added a comment -

        It is very strange that the doctrine inheritance system don't inherite all the relationship of the mother-table on all sub-table. I think that it will be a very good improvement to fix this problem.

        For example if you are this model :

        Unable to find source-code formatter for language: yml. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
         
        motherTable:
          columns:
             code: string
             relationTable_id: integer
          relation:
             relationTableRelation:
                    local: relationTable_id
                    foreign: id
                    type: one     
        
        subTable:
            inheritance:
                type: concrete
            colums:
                name: string
        
        relationTable:
            columns:
                code: integer
            relations:
                motherTableRelation:
                    local: id
                    foreign: relationTable_id
                    type: many
        

        In this example, the relationTableRelation will be inherited, it is good but the other side of the relation in relation table will always go on motherTable and not on subTable, but motherTable is always empty, moreover subTable don't share its ID with motherTable, so this side of the relationship is unusefull because we can find subTable element in relation with a relationTable element.

        It will be good to find a solution to this issue

        Show
        TD added a comment - It is very strange that the doctrine inheritance system don't inherite all the relationship of the mother-table on all sub-table. I think that it will be a very good improvement to fix this problem. For example if you are this model : Unable to find source-code formatter for language: yml. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml motherTable: columns: code: string relationTable_id: integer relation: relationTableRelation: local: relationTable_id foreign: id type: one subTable: inheritance: type: concrete colums: name: string relationTable: columns: code: integer relations: motherTableRelation: local: id foreign: relationTable_id type: many In this example, the relationTableRelation will be inherited, it is good but the other side of the relation in relation table will always go on motherTable and not on subTable, but motherTable is always empty, moreover subTable don't share its ID with motherTable, so this side of the relationship is unusefull because we can find subTable element in relation with a relationTable element. It will be good to find a solution to this issue

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Julien Chiron
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: