[DC-443] Incorrect insert order in i18n entities Created: 22/Jan/10  Updated: 22/Jan/10

Status: Open
Project: Doctrine 1
Component/s: I18n, Relations
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Rodrigo Borrego Bernabé Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None

Linux (2.6.21 kernel)
PHP 5.2.6
symfony version 1.4.1
doctrine 1.2

Attachments: File i18nrelation_problem.tgz    


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

      fields: [a,b,c,d, e]
    a:  { type: string(255), notnull: true }
    b:  { type: string(255), notnull: true }
    c:  string
    d:  string
    e:  string

    my_main_id:  integer
    a:        string(255)
    b:        string(255)
      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 

Generated at Tue Dec 01 02:45:57 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.