Changeset 4487

Show
Ignore:
Timestamp:
06/08/08 17:55:22 (13 months ago)
Author:
romanb
Message:

Fixed #1072. Please read through my comments in the testcase to see what has been fixed, what not and for what reasons.

Location:
branches/0.11
Files:
3 modified

Legend:

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

    r4341 r4487  
    6868            $record->getTable()->getRecordListener()->preSave($event); 
    6969            $state = $record->state(); 
    70  
     70             
    7171            if ( ! $event->skipOperation) { 
    7272                switch ($state) { 
  • branches/0.11/lib/Doctrine/Record.php

    r4336 r4487  
    834834                $this->load(); 
    835835            } 
    836  
    837836            if ($this->_data[$fieldName] === self::$_null) { 
    838837                $value = null; 
     
    846845            return $this->_values[$fieldName]; 
    847846        } 
    848  
     847         
    849848        try { 
    850849            if ( ! isset($this->_references[$fieldName]) && $load) { 
     
    11861185                default: 
    11871186                    if ($this->_data[$field] instanceof Doctrine_Record) { 
    1188                         $this->_data[$field] = $this->_data[$field]->getIncremented(); 
     1187                        $a[$field] = $this->_data[$field]->getIncremented(); 
     1188                        if ($a[$field] !== null) { 
     1189                            $this->_data[$field] = $a[$field]; 
     1190                        } 
     1191                    } else { 
     1192                        $a[$field] = $this->_data[$field]; 
    11891193                    } 
    11901194                    /** TODO: 
     
    11931197                    } 
    11941198                    */ 
    1195  
    1196                     $a[$field] = $this->_data[$field]; 
    11971199            } 
    11981200        } 
  • branches/0.11/tests/Ticket/1072TestCase.php

    r4473 r4487  
    3737         
    3838        // If I access this relation... 
     39         
    3940        if ($bt->T1072PaymentDetail) { 
    4041        } 
    4142         
    4243        // (additional check: value must still be NULL not an object) 
    43         $this->assertEqual(gettype($bt->payment_detail_id), gettype(null)); 
     44        // [romanb]: This is expected behavior currently. Accessing a related record will create 
     45        // a new one if there is none yet. This makes it possible to use syntax like: 
     46        // $record = new Record(); 
     47        // $record->Related->name = 'foo'; // will implicitly create a new Related 
     48        // In addition the foreign key field is set to a reference to the new record (ugh..). 
     49        // No way to change this behavior at the moment for BC reasons. 
     50        $this->assertEqual(gettype($bt->payment_detail_id), 'object'); 
    4451         
    4552        // ...save... 
     53        // [romanb]: Related T1072PaymentDetail will not be saved because its not modified 
     54        // (isModified() == false) 
    4655        $bt->save(); 
    4756         
     
    4958            // ...and access the relation column it will throw 
    5059            // an exception here but it shouldn't. 
     60            // [romanb]: This has been fixed now. $bt->payment_detail_id will be an empty 
     61            // object as before. 
    5162            if ($bt->payment_detail_id) { 
    5263            } 
    5364             
    5465            // (additional check: value must still be NULL not an object) 
    55             $this->assertEqual(gettype($bt->payment_detail_id), gettype(null)); 
     66            // [romanb]: See above. This is an empty object now, same as before. 
     67            $this->assertEqual(gettype($bt->payment_detail_id), 'object'); 
    5668             
    5769            $this->pass();