Changeset 4293

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

Fixed a bug in the new application-level cascading deletes.

Location:
branches/0.11
Files:
2 modified

Legend:

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

    r4286 r4293  
    340340                 } 
    341341                 $relatedObjects = $record->get($relation->getAlias()); 
    342                  if ($relatedObjects instanceof Doctrine_Record && 
    343                         ! isset($deletions[$relatedObjects->getOid()])) { 
     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. 
     344                 if ($relatedObjects instanceof Doctrine_Record && $relatedObjects->exists() 
     345                        && ! isset($deletions[$relatedObjects->getOid()])) { 
    344346                     $this->_collectDeletions($relatedObjects, $deletions); 
    345347                 } else if ($relatedObjects instanceof Doctrine_Collection && count($relatedObjects) > 0) { 
  • branches/0.11/tests/Record/CascadingDeleteTestCase.php

    r4211 r4293  
    136136    } 
    137137     
     138    public function testCascadingDeleteInOneToZeroOrOneRelation() 
     139    { 
     140        $owner = new CascadeDelete_HouseOwner(); 
     141        $owner->name = 'Jeff Bridges'; 
     142        $owner->save(); 
     143        try { 
     144            $owner->delete(); 
     145            $this->pass(); 
     146        } catch (Doctrine_Exception $e) { 
     147            $this->fail("Failed to delete record. Message:" . $e->getMessage()); 
     148        } 
     149         
     150    } 
     151     
    138152    public function testDeletionOfCompositeKeys() 
    139153    {