[DC-1057] Inserts instead of updates for related objects Created: 20/Jul/12 Updated: 20/Jul/12 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Relations |
| Affects Version/s: | 1.2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Grzegorz Godlewski | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
linux, apache2, php 5.3 |
||
| Description |
|
Ok, so the object relations go like this:
The testing code looks like following: == CODE START == Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml $comp = new Application_Model_Comparison(); /* Filling $comp with data */ for ($i = 0; $i < 10; $i++) { $product = new Application_Model_Product(); // Options referenced in Rules $options = array(); for ($j = 0; $j < 10; $j++) { $param = new Application_Model_Parameter(); for ($k = 0; $k < 10; $k++) { $option = new Application_Model_Option(); $param->Options->add($option); // Register a single option for this parameter if (!isset($options[$j])) { $options[$j] = $option; } } $product->Parameters->add($param); } for ($j = 0; $j < 10; $j++) { $rule = new Application_Model_Rule(); $rule->Option = $options[$j]; $product->Rules->add($rule); } $comp->Products->add($product); } /** * The first save() goes nicely, all objects * are created (INSERTed) */ $comp->save(); // Remove every second product $pCount = $comp->Products->count(); for ($i = 0; $i < $pCount; $i += 2) { $comp->Products->remove($i); } /** * Fails while trying to save * * Comparison->Product->Parameter->Option * INSERT ... `parameter_id` cannot be NULL * * Comparison->Product->Rule * INSERT ... `product_id` cannot be NULL */ $comp->save(); == CODE END == The first save() cleans up the relation information in the graph. All child objects are INSERTED instead of UPDATE. |