Changeset 4778
- Timestamp:
- 08/19/08 01:27:22 (11 months ago)
- Location:
- branches/1.0
- Files:
-
- 1 added
- 8 modified
-
lib/Doctrine/DataDict/Mysql.php (modified) (1 diff)
-
lib/Doctrine/DataDict/Pgsql.php (modified) (1 diff)
-
lib/Doctrine/DataDict/Sqlite.php (modified) (1 diff)
-
lib/Doctrine/Export.php (modified) (2 diffs)
-
lib/Doctrine/Export/Mysql.php (modified) (1 diff)
-
lib/Doctrine/Record.php (modified) (1 diff)
-
lib/Doctrine/Record/Abstract.php (modified) (1 diff)
-
tests/run.php (modified) (1 diff)
-
tests/Ticket/1280TestCase.php (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/lib/Doctrine/DataDict/Mysql.php
r4768 r4778 458 458 $field['default'] = empty($field['notnull']) ? null : 0; 459 459 } 460 if (is_null($field['default'])) { 461 $default = ' DEFAULT NULL'; 462 } else { 463 $default = ' DEFAULT '.$this->conn->quote($field['default']); 464 } 460 461 $default = ' DEFAULT ' . (is_null($field['default']) 462 ? 'NULL' 463 : $this->conn->quote($field['default'])); 465 464 } 466 465 /** -
branches/1.0/lib/Doctrine/DataDict/Pgsql.php
r4768 r4778 614 614 $field['default'] = empty($field['notnull']) ? null : 0; 615 615 } 616 $default = ' DEFAULT '.$this->conn->quote($field['default'], $field['type']); 616 617 $default = ' DEFAULT ' . (is_null($field['default']) 618 ? 'NULL' 619 : $this->conn->quote($field['default'], $field['type'])); 617 620 } 618 621 /** -
branches/1.0/lib/Doctrine/DataDict/Sqlite.php
r4768 r4778 296 296 $field['default'] = empty($field['notnull']) ? null : 0; 297 297 } 298 $default = ' DEFAULT ' . $this->conn->quote($field['default'], $field['type']); 298 299 $default = ' DEFAULT ' . (is_null($field['default']) 300 ? 'NULL' 301 : $this->conn->quote($field['default'], $field['type'])); 299 302 }/** 300 303 elseif (empty($field['notnull'])) { -
branches/1.0/lib/Doctrine/Export.php
r4736 r4778 752 752 { 753 753 $default = ''; 754 if (isset($field['default'])) { 754 755 if (array_key_exists('default', $field)) { 755 756 if ($field['default'] === '') { 756 757 $field['default'] = empty($field['notnull']) … … 766 767 $field['default'] = $this->conn->convertBooleans($field['default']); 767 768 } 768 $default = ' DEFAULT ' . $this->conn->quote($field['default'], $field['type']); 769 } 769 $default = ' DEFAULT ' . (is_null($field['default']) 770 ? 'NULL' 771 : $this->conn->quote($field['default'], $field['type'])); 772 } 773 770 774 return $default; 771 775 } -
branches/1.0/lib/Doctrine/Export/Mysql.php
r4731 r4778 605 605 } 606 606 607 $default = ' DEFAULT ' . $this->conn->quote($field['default'], $fieldType); 607 $default = ' DEFAULT ' . (is_null($field['default']) 608 ? 'NULL' 609 : $this->conn->quote($field['default'], $fieldType)); 608 610 //$default = ' DEFAULT ' . $this->conn->quote($field['default'], $field['type']); 609 611 } 612 610 613 return $default; 611 614 } -
branches/1.0/lib/Doctrine/Record.php
r4772 r4778 1035 1035 throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references."); 1036 1036 } 1037 1037 1038 if (isset($this->_references[$name])) { 1038 1039 $this->_references[$name]->setData($value->getData()); 1040 1039 1041 return $this; 1040 1042 } 1041 1043 } else { 1044 $localFieldName = $this->_table->getFieldName($rel->getLocal()); 1045 1042 1046 if ($value !== self::$_null) { 1043 1047 $relatedTable = $value->getTable(); 1044 1048 $foreignFieldName = $relatedTable->getFieldName($rel->getForeign()); 1045 $localFieldName = $this->_table->getFieldName($rel->getLocal()); 1046 1047 // one-to-one relation found 1048 if ( ! ($value instanceof Doctrine_Record)) { 1049 throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record or Doctrine_Null when setting one-to-one references."); 1049 } 1050 1051 // one-to-one relation found 1052 if ( ! ($value instanceof Doctrine_Record) && ! ($value instanceof Doctrine_Null)) { 1053 throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record or Doctrine_Null when setting one-to-one references."); 1054 } 1055 1056 if ($rel instanceof Doctrine_Relation_LocalKey) { 1057 if ($value !== self::$_null && ! empty($foreignFieldName) && $foreignFieldName != $value->getTable()->getIdentifier()) { 1058 $this->set($localFieldName, $value->rawGet($foreignFieldName), false); 1059 } else { 1060 // FIX: Ticket #1280 fits in this situation 1061 $this->set($localFieldName, $value, false); 1050 1062 } 1051 if ($rel instanceof Doctrine_Relation_LocalKey) { 1052 if ( ! empty($foreignFieldName) && $foreignFieldName != $value->getTable()->getIdentifier()) { 1053 $this->set($localFieldName, $value->rawGet($foreignFieldName), false); 1054 } else { 1055 $this->set($localFieldName, $value, false); 1056 } 1057 } else { 1058 $value->set($foreignFieldName, $this, false); 1059 } 1063 } elseif ($value !== self::$_null) { 1064 // We should only be able to reach $foreignFieldName if we have a Doctrine_Record on hands 1065 $value->set($foreignFieldName, $this, false); 1060 1066 } 1061 1067 } 1062 1063 1068 } else if ($rel instanceof Doctrine_Relation_Association) { 1064 1069 // join table relation found -
branches/1.0/lib/Doctrine/Record/Abstract.php
r4681 r4778 40 40 public function setTableDefinition() 41 41 { 42 42 43 43 } 44 44 public function setUp() -
branches/1.0/tests/run.php
r4777 r4778 115 115 $tickets->addTestCase(new Doctrine_Ticket_1257_TestCase()); 116 116 $tickets->addTestCase(new Doctrine_Ticket_1277_TestCase()); 117 $tickets->addTestCase(new Doctrine_Ticket_1280_TestCase()); 117 118 $tickets->addTestCase(new Doctrine_Ticket_1289_TestCase()); 118 119 $tickets->addTestCase(new Doctrine_Ticket_1296_TestCase());