[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 | ||
| Environment: |
Linux (2.6.21 kernel) |
||
| Attachments: |
|
| 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. 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 |