Changeset 4294

Show
Ignore:
Timestamp:
04/25/08 19:55:17 (15 months ago)
Author:
romanb
Message:

Changed the deletion to simply ignore transient objects in general. This is a much better behavior (in fact this is how it used to be in the past).

Location:
branches/0.11
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Connection/UnitOfWork.php

    r4293 r4294  
    181181    { 
    182182        if ( ! $record->exists()) { 
    183             throw new Doctrine_Connection_Exception("Transient records can't be deleted."); 
     183            return; 
    184184        } 
    185185 
     
    340340                 } 
    341341                 $relatedObjects = $record->get($relation->getAlias()); 
    342                  // note: The exists() check is needed because a related object is created 
    343                  // on-the-fly on access and we need to make sure it's not such an object. 
    344342                 if ($relatedObjects instanceof Doctrine_Record && $relatedObjects->exists() 
    345343                        && ! isset($deletions[$relatedObjects->getOid()])) { 
  • branches/0.11/tests/ConnectionTestCase.php

    r4211 r4294  
    150150    } 
    151151 
    152     public function testDeleteOnTransientRecordThrowsException()  
     152    public function testDeleteOnTransientRecordIsIgnored()  
    153153    { 
    154154        $user = $this->connection->create('User'); 
    155155        try { 
    156156            $this->connection->unitOfWork->delete($user); 
     157        } catch (Doctrine_Connection_Exception $e) { 
    157158            $this->fail(); 
    158         } catch (Doctrine_Connection_Exception $e) { 
    159             $this->pass(); 
    160159        } 
    161160    } 
  • branches/0.11/tests/RecordTestCase.php

    r4286 r4294  
    985985        $this->assertTrue($user->delete()); 
    986986        try { 
     987          // delete() on transient objects should just be ignored. 
    987988          $user->delete(); 
     989        } catch (Exception $e) { 
    988990          $this->fail(); 
    989         } catch (Exception $e) { 
    990           $this->pass(); 
    991991        } 
    992992    }