Changeset 4487
- Timestamp:
- 06/08/08 17:55:22 (13 months ago)
- Location:
- branches/0.11
- Files:
-
- 3 modified
-
lib/Doctrine/Connection/UnitOfWork.php (modified) (1 diff)
-
lib/Doctrine/Record.php (modified) (4 diffs)
-
tests/Ticket/1072TestCase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/lib/Doctrine/Connection/UnitOfWork.php
r4341 r4487 68 68 $record->getTable()->getRecordListener()->preSave($event); 69 69 $state = $record->state(); 70 70 71 71 if ( ! $event->skipOperation) { 72 72 switch ($state) { -
branches/0.11/lib/Doctrine/Record.php
r4336 r4487 834 834 $this->load(); 835 835 } 836 837 836 if ($this->_data[$fieldName] === self::$_null) { 838 837 $value = null; … … 846 845 return $this->_values[$fieldName]; 847 846 } 848 847 849 848 try { 850 849 if ( ! isset($this->_references[$fieldName]) && $load) { … … 1186 1185 default: 1187 1186 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]; 1189 1193 } 1190 1194 /** TODO: … … 1193 1197 } 1194 1198 */ 1195 1196 $a[$field] = $this->_data[$field];1197 1199 } 1198 1200 } -
branches/0.11/tests/Ticket/1072TestCase.php
r4473 r4487 37 37 38 38 // If I access this relation... 39 39 40 if ($bt->T1072PaymentDetail) { 40 41 } 41 42 42 43 // (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'); 44 51 45 52 // ...save... 53 // [romanb]: Related T1072PaymentDetail will not be saved because its not modified 54 // (isModified() == false) 46 55 $bt->save(); 47 56 … … 49 58 // ...and access the relation column it will throw 50 59 // 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. 51 62 if ($bt->payment_detail_id) { 52 63 } 53 64 54 65 // (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'); 56 68 57 69 $this->pass();