Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Record
-
Labels:None
-
Environment:Ubuntu 9.10, PHP 5.2.10, pgsql 8.3
Description
Here is an example:
class Article extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('title', 'string', 255); $this->hasColumn('body', 'string', 4096); } public function setUp() { $this->hasMany('Comment as Comments', array( 'local' => 'id', 'foreign' => 'articleId', )); } } class Comment extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('comment', 'string', 4096); $this->hasColumn('articleId', 'integer'); } public function setUp() { $this->hasOne('Article', array( 'local' => 'articleId', 'foreign' => 'id', )); } public function preUpdate($e) { throw new Exception('should not get here'); } } $a = new Article(); $a->title = 'Hi'; $a->body = 'There'; $a->save(); $c = new Comment(); $c->comment = '1st comment'; $c->articleId = $a->id; $c->save(); $a->refreshRelated('Comments'); $a->title = 'Hello'; $a->save();
What happens above is that the call to refreshRelated() causes the 'id' of the comment to change from string:1 to int:1, which causes the last save of the article to try to save the comment. The exception is there just to illustrate that the Comment is being updated (which should not happen). For us - this is an issue not just because of the extra query, but because some entities in the system (like log entries) actually throw when updated.
Tested against latest trunk.
The issue seems to be introduced in r7361.