From f6bb8c97268dc03921587001c83f7527244a030b Mon Sep 17 00:00:00 2001
From: zYne <zYne@625475ce-881a-0410-a577-b389adb331d8>
Date: Tue, 22 May 2007 18:09:54 +0000
Subject: [PATCH]

---
 lib/Doctrine/Collection.php | 10 ++++++++++
 lib/Doctrine/Connection.php |  2 +-
 lib/Doctrine/Record.php     |  7 +++++--
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php
index d8f93be00..4bf914e76 100644
--- a/lib/Doctrine/Collection.php
+++ b/lib/Doctrine/Collection.php
@@ -105,6 +105,16 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
     {
         return $this->_table;
     }
+    /**
+     * setData
+     *
+     * @param array $data
+     * @return Doctrine_Collection
+     */
+    public function setData(array $data) 
+    {
+    	$this->data = $data;
+    }
     /**
      * this method is automatically called when this Doctrine_Collection is serialized
      *
diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php
index c5aa20776..dfb8705ff 100644
--- a/lib/Doctrine/Connection.php
+++ b/lib/Doctrine/Connection.php
@@ -696,7 +696,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
         } catch(Doctrine_Adapter_Exception $e) {
         } catch(PDOException $e) { }
 
-        
+         print Doctrine_Lib::formatSql($query);
         $this->rethrowException($e);
     }
     /**
diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php
index 15b245d71..a256a2332 100644
--- a/lib/Doctrine/Record.php
+++ b/lib/Doctrine/Record.php
@@ -488,7 +488,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
         foreach($array as $k => $v) {
             $this->$k = $v;
         }
-        
+
         $this->_table->getRepository()->add($this);
         $this->_filter = new Doctrine_Record_Filter($this);
 
@@ -825,7 +825,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
                 if ( ! ($value instanceof Doctrine_Collection)) {
                     throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references.");
                 }
-                $value->setReference($this,$rel);
+                if (isset($this->_references[$name])) {
+                    $this->_references[$name]->setData($value->getData());
+                    return $this;
+                }
             } else {
                 // one-to-one relation found
                 if ( ! ($value instanceof Doctrine_Record)) {