Doctrine 1
  1. Doctrine 1
  2. DC-443

Incorrect insert order in i18n entities

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: I18n, Relations
    • Labels:
      None
    • Environment:
      Linux (2.6.21 kernel)
      Apache/2.2.6
      PHP 5.2.6
      symfony version 1.4.1
      doctrine 1.2

      Description

      If the schema has an entity MyMain with all its fields i18n and an entity MySecondary related to MyMain and you try to create a new MySecondary item using Symfony forms you get an error.

      I think the error is doctrine and in i18n because if you remove a field from the i18n behavior (fields: [a,b,c,d], for example) all works ok.
      I've included a symfony project to help developpers replicate the error.

      My Schema

       
      MyMain:
        actAs:
          I18n:
            fields: [a,b,c,d, e]
        columns:
          a:  { type: string(255), notnull: true }
          b:  { type: string(255), notnull: true }
          c:  string
          d:  string
          e:  string
      
      MySecondary:
        columns:
          my_main_id:  integer
          a:        string(255)
          b:        string(255)
        relations:
          MyMain:
            local: my_main_id
            foreign: id
            foreignType: one
            cascade: [delete]
      

      And the form code

      class MyMainForm extends BaseMyMainForm
      {
        public function configure()
        {
          $this->embedI18n(array('en', 'es'));
        }
      }
      
      class MySecondaryForm extends BaseMySecondaryForm
      {
        public function configure()
        {
          $this->widgetSchema['my_main_id'] = new sfWidgetFormInputHidden();
          $this->embedRelation('MyMain as main_subform');
        }
      }
      

      And last the queries (and its order when you get the error)

      INSERT INTO my_secondary (my_main_id, a, b) VALUES (?, ?, ?) - (, my_secondary[a], my_secondary[b])
      INSERT INTO my_main_translation (id, lang, a, b, c, d, e) VALUES (?, ?, ?, ?, ?, ?, ?) - 
        (, en, my_secondary[main_subform][en][a], my_secondary[main_subform][en][b], my_secondary[main_subform][en][c], 
         my_secondary[main_subform][en][d], my_secondary[main_subform][en][e])
      Error Doctrine_Connection_Mysql_Exception	SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'id' cannot be null 
      
      1. i18nrelation_problem.tgz
        27 kB
        Rodrigo Borrego Bernabé

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Rodrigo Borrego Bernabé
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: