[DC-489] Doctrine_Record seems to have a bug with default values when updating Created: 10/Feb/10 Updated: 20/Jan/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Record |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Silver | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
PHP 5.2.11 |
||
| Description |
|
So lets see the table: User:
So lets say we have a user with `role` = 'support' and want to set em $user = new App_Model_User(); in debugger we see SQL query been made:
array(6) { ["id"]=> int(1) ["display_name"]=> string(13) "Administrator" ["username"]=> string(4) "root" ["password"]=> string(40) "45bb0f589525a2f0f2a48620bb59b1b8baef0c1d" ["role"]=> string(5) "admin" ["is_active"]=> bool(true) }Superb! Works as it should! So lets now set role of this user back to $user = new App_Model_User(); in debugger we didnot see any UPDATE queries! However object is been array(6) { ["id"]=> int(1) ["display_name"]=> string(13) "Administrator" ["username"]=> string(4) "root" ["password"]=> string(40) "45bb0f589525a2f0f2a48620bb59b1b8baef0c1d" ["role"]=> string(7) "support" ["is_active"]=> bool(true) }I cant overcome this problem right now, unfortunatelly (well I can However if I use Doctrine_Query of even $user = Doctrine_Core::getTable('App_Model_User')->find(1); instead of $user = new App_Model_User(); updates works well... |
| Comments |
| Comment by Petr Peller [ 20/Jan/11 ] |
|
I second this. When you UPDATE row with save() method of Record after setting identifier by assignIdentifier() doctrine removes columns updates from SQL which are set to default values same as it would do with INSERT. Other columns are updated correctly. This is sure a bug. You can workaround this by setting the value as NULL instead of the actual default value. (Which I wouldn't recommend). |