Details
Description
There is no possibility to delete a reference on a OneToOne-Relation with synchronizeWithArray().
If User and Group would be OneToOne related, i would expect that I could do something like the following (like on ManyToMany-Relations), to delete the relation between both.
$user->synchronizeWithArray(array(
'Group' => array() // no error, but the relation is not deleted
));
or
$user->synchronizeWithArray(array(
'Group' => array(null) // error, cause doctrine expects an existing ID
));
This fixes the problem:
Index: library/Doctrine/Record.php
===================================================================
--- library/Doctrine/Record.php (revision 6903)
+++ library/Doctrine/Record.php (working copy)
@@ -2012,6 +2012,8 @@
if (isset($value[0]) && ! is_array($value[0])) {
$this->unlink($key, array(), false);
$this->link($key, $value, false);
+ } else if (empty($value) || (null === current($value))) {
+ $this->unlink($key, array(), false);
} else {
$this->$key->synchronizeWithArray($value);
}
Hmm. The second syntax is weird. I think the first syntax makes more sense, no?