Author: Frederik Holljen
Date: 2007-02-02 11:43:07 +0100 (Fri, 02 Feb 2007)
New Revision: 4622

Log:
- update() now uses the persistence check in the generator to determine if an 
should be saved or not.
- this triggered an error in one of the relations tests, toby checks it out 
later.

Modified:
   trunk/DatabaseSchema/src/handlers/mysql/reader.php
   trunk/PersistentObject/src/persistent_session.php
   trunk/PersistentObject/tests/one_to_one_relation_test.php

Modified: trunk/DatabaseSchema/src/handlers/mysql/reader.php
===================================================================
--- trunk/DatabaseSchema/src/handlers/mysql/reader.php  2007-02-02 09:43:11 UTC 
(rev 4621)
+++ trunk/DatabaseSchema/src/handlers/mysql/reader.php  2007-02-02 10:43:07 UTC 
(rev 4622)
@@ -122,6 +122,7 @@
     {
         $fields = array();
 
+        var_dump( "DESCRIBE $tableName" );
         $resultArray = $this->db->query( "DESCRIBE $tableName" );
         $resultArray->setFetchMode( PDO::FETCH_ASSOC );
 

Modified: trunk/PersistentObject/src/persistent_session.php
===================================================================
--- trunk/PersistentObject/src/persistent_session.php   2007-02-02 09:43:11 UTC 
(rev 4621)
+++ trunk/PersistentObject/src/persistent_session.php   2007-02-02 10:43:07 UTC 
(rev 4622)
@@ -972,9 +972,21 @@
         $state = $this->filterAndCastState( $pObject->getState(), $def );
         $idValue = $state[$def->idProperty->propertyName];
 
-        // check that this object is stored to db already
-        if (  $idValue === null )
+        // fetch the id generator
+        $idGenerator = null;
+        if ( ezcBaseFeatures::classExists( $def->idProperty->generator->class 
) )
         {
+            $idGenerator = new $def->idProperty->generator->class;
+            if ( !( $idGenerator instanceof ezcPersistentIdentifierGenerator ) 
)
+            {
+                throw new ezcPersistentIdentifierGenerationException( 
get_class( $pObject ),
+                                                                      "Could 
not initialize identifier generator: ". "{$def->idProperty->generator->class} 
." );
+            }
+        }
+
+        if ( !$idGenerator->checkPersistence( $def, $this->database, $state ) )
+        {
+            $class = get_class( $pObject );
             throw new ezcPersistentObjectNotPersistentException( get_class( 
$pObject ) );
         }
 

Modified: trunk/PersistentObject/tests/one_to_one_relation_test.php
===================================================================
--- trunk/PersistentObject/tests/one_to_one_relation_test.php   2007-02-02 
09:43:11 UTC (rev 4621)
+++ trunk/PersistentObject/tests/one_to_one_relation_test.php   2007-02-02 
10:43:07 UTC (rev 4622)
@@ -301,7 +301,7 @@
         ) );
 
         $this->session->addRelatedObject( $person, $birthday );
-        
+
         $this->session->update( $birthday );
         
         try

-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to