Changeset 5030
- Timestamp:
- 10/02/08 05:46:18 (3 months ago)
- Location:
- branches/1.1
- Files:
-
- 1 added
- 7 modified
-
lib/Doctrine.php (modified) (1 diff)
-
lib/Doctrine/Configurable.php (modified) (1 diff)
-
lib/Doctrine/Manager.php (modified) (1 diff)
-
lib/Doctrine/Record/Abstract.php (modified) (1 diff)
-
lib/Doctrine/Table.php (modified) (5 diffs)
-
tests/run.php (modified) (2 diffs)
-
tests/Ticket/753TestCase.php (added)
-
UPGRADE_TO_1_1 (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1/lib/Doctrine.php
r5027 r5030 177 177 const ATTR_DEFAULT_SEQUENCE = 133; 178 178 179 const ATTR_FETCHMODE = 118; 180 const ATTR_NAME_PREFIX = 121; 181 const ATTR_CREATE_TABLES = 122; 182 const ATTR_COLL_LIMIT = 123; 183 184 const ATTR_CACHE = 150; 185 const ATTR_RESULT_CACHE = 150; 186 const ATTR_CACHE_LIFESPAN = 151; 187 const ATTR_RESULT_CACHE_LIFESPAN = 151; 188 const ATTR_LOAD_REFERENCES = 153; 189 const ATTR_RECORD_LISTENER = 154; 190 const ATTR_THROW_EXCEPTIONS = 155; 191 const ATTR_DEFAULT_PARAM_NAMESPACE = 156; 192 const ATTR_QUERY_CACHE = 157; 193 const ATTR_QUERY_CACHE_LIFESPAN = 158; 194 const ATTR_AUTOLOAD_TABLE_CLASSES = 160; 195 const ATTR_MODEL_LOADING = 161; 196 const ATTR_RECURSIVE_MERGE_FIXTURES = 162; 197 const ATTR_USE_DQL_CALLBACKS = 164; 198 const ATTR_AUTO_ACCESSOR_OVERRIDE = 165; 199 const ATTR_AUTO_FREE_QUERY_OBJECTS = 166; 200 const ATTR_DEFAULT_TABLE_CHARSET = 167; 201 const ATTR_DEFAULT_TABLE_COLLATE = 168; 179 const ATTR_FETCHMODE = 118; 180 const ATTR_NAME_PREFIX = 121; 181 const ATTR_CREATE_TABLES = 122; 182 const ATTR_COLL_LIMIT = 123; 183 184 const ATTR_CACHE = 150; 185 const ATTR_RESULT_CACHE = 150; 186 const ATTR_CACHE_LIFESPAN = 151; 187 const ATTR_RESULT_CACHE_LIFESPAN = 151; 188 const ATTR_LOAD_REFERENCES = 153; 189 const ATTR_RECORD_LISTENER = 154; 190 const ATTR_THROW_EXCEPTIONS = 155; 191 const ATTR_DEFAULT_PARAM_NAMESPACE = 156; 192 const ATTR_QUERY_CACHE = 157; 193 const ATTR_QUERY_CACHE_LIFESPAN = 158; 194 const ATTR_AUTOLOAD_TABLE_CLASSES = 160; 195 const ATTR_MODEL_LOADING = 161; 196 const ATTR_RECURSIVE_MERGE_FIXTURES = 162; 197 const ATTR_USE_DQL_CALLBACKS = 164; 198 const ATTR_AUTO_ACCESSOR_OVERRIDE = 165; 199 const ATTR_AUTO_FREE_QUERY_OBJECTS = 166; 200 const ATTR_DEFAULT_TABLE_CHARSET = 167; 201 const ATTR_DEFAULT_TABLE_COLLATE = 168; 202 const ATTR_DEFAULT_IDENTIFIER_OPTIONS = 169; 203 const ATTR_DEFAULT_COLUMN_OPTIONS = 170; 202 204 203 205 /** -
branches/1.1/lib/Doctrine/Configurable.php
r5027 r5030 186 186 case Doctrine::ATTR_DEFAULT_TABLE_CHARSET; 187 187 case Doctrine::ATTR_DEFAULT_TABLE_COLLATE; 188 case Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS; 189 case Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS; 188 190 189 191 break; -
branches/1.1/lib/Doctrine/Manager.php
r5018 r5030 83 83 $init = true; 84 84 $attributes = array( 85 Doctrine::ATTR_CACHE => null, 86 Doctrine::ATTR_RESULT_CACHE => null, 87 Doctrine::ATTR_QUERY_CACHE => null, 88 Doctrine::ATTR_LOAD_REFERENCES => true, 89 Doctrine::ATTR_LISTENER => new Doctrine_EventListener(), 90 Doctrine::ATTR_RECORD_LISTENER => new Doctrine_Record_Listener(), 91 Doctrine::ATTR_THROW_EXCEPTIONS => true, 92 Doctrine::ATTR_VALIDATE => Doctrine::VALIDATE_NONE, 93 Doctrine::ATTR_QUERY_LIMIT => Doctrine::LIMIT_RECORDS, 94 Doctrine::ATTR_IDXNAME_FORMAT => "%s_idx", 95 Doctrine::ATTR_SEQNAME_FORMAT => "%s_seq", 96 Doctrine::ATTR_TBLNAME_FORMAT => "%s", 97 Doctrine::ATTR_QUOTE_IDENTIFIER => false, 98 Doctrine::ATTR_SEQCOL_NAME => 'id', 99 Doctrine::ATTR_PORTABILITY => Doctrine::PORTABILITY_NONE, 100 Doctrine::ATTR_EXPORT => Doctrine::EXPORT_ALL, 101 Doctrine::ATTR_DECIMAL_PLACES => 2, 102 Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE => 'doctrine', 103 Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES => false, 104 Doctrine::ATTR_USE_DQL_CALLBACKS => false, 105 Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE => false, 106 Doctrine::ATTR_AUTO_FREE_QUERY_OBJECTS => false, 85 Doctrine::ATTR_CACHE => null, 86 Doctrine::ATTR_RESULT_CACHE => null, 87 Doctrine::ATTR_QUERY_CACHE => null, 88 Doctrine::ATTR_LOAD_REFERENCES => true, 89 Doctrine::ATTR_LISTENER => new Doctrine_EventListener(), 90 Doctrine::ATTR_RECORD_LISTENER => new Doctrine_Record_Listener(), 91 Doctrine::ATTR_THROW_EXCEPTIONS => true, 92 Doctrine::ATTR_VALIDATE => Doctrine::VALIDATE_NONE, 93 Doctrine::ATTR_QUERY_LIMIT => Doctrine::LIMIT_RECORDS, 94 Doctrine::ATTR_IDXNAME_FORMAT => "%s_idx", 95 Doctrine::ATTR_SEQNAME_FORMAT => "%s_seq", 96 Doctrine::ATTR_TBLNAME_FORMAT => "%s", 97 Doctrine::ATTR_QUOTE_IDENTIFIER => false, 98 Doctrine::ATTR_SEQCOL_NAME => 'id', 99 Doctrine::ATTR_PORTABILITY => Doctrine::PORTABILITY_NONE, 100 Doctrine::ATTR_EXPORT => Doctrine::EXPORT_ALL, 101 Doctrine::ATTR_DECIMAL_PLACES => 2, 102 Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE => 'doctrine', 103 Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES => false, 104 Doctrine::ATTR_USE_DQL_CALLBACKS => false, 105 Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE => false, 106 Doctrine::ATTR_AUTO_FREE_QUERY_OBJECTS => false, 107 Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS => array(), 108 Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS => array() 107 109 ); 108 110 foreach ($attributes as $attribute => $value) { -
branches/1.1/lib/Doctrine/Record/Abstract.php
r4957 r5030 225 225 * @return void 226 226 */ 227 public function hasColumn($name, $type , $length = 2147483647, $options = "")227 public function hasColumn($name, $type = null, $length = null, $options = array()) 228 228 { 229 229 $this->_table->setColumn($name, $type, $length, $options); -
branches/1.1/lib/Doctrine/Table.php
r5027 r5030 411 411 } 412 412 } else { 413 $definition = array('type' => 'integer', 414 'length' => 20, 415 'autoincrement' => true, 416 'primary' => true); 417 $this->setColumn('id', $definition['type'], $definition['length'], $definition, true); 418 $this->_identifier = 'id'; 413 $identifierOptions = $this->getAttribute(Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS); 414 $name = (isset($identifierOptions['name']) && $identifierOptions['name']) ? $identifierOptions['name']:'id'; 415 $name = sprintf($name, $this->getTableName()); 416 417 $definition = array('type' => (isset($identifierOptions['type']) && $identifierOptions['type']) ? $identifierOptions['type']:'integer', 418 'length' => (isset($identifierOptions['length']) && $identifierOptions['length']) ? $identifierOptions['length']:20, 419 'autoincrement' => isset($identifierOptions['autoincrement']) ? $identifierOptions['autoincrement']:true, 420 'primary' => isset($identifierOptions['primary']) ? $identifierOptions['primary']:true); 421 422 unset($identifierOptions['name'], $identifierOptions['type'], $identifierOptions['length']); 423 foreach ($identifierOptions as $key => $value) { 424 if ( ! isset($definition[$key]) || ! $definition[$key]) { 425 $definition[$key] = $value; 426 } 427 } 428 429 $this->setColumn($name, $definition['type'], $definition['length'], $definition, true); 430 $this->_identifier = $name; 419 431 $this->_identifierType = Doctrine::IDENTIFIER_AUTOINC; 420 432 } … … 983 995 * @return void 984 996 */ 985 public function setColumn($name, $type , $length = null, $options = array(), $prepend = false)997 public function setColumn($name, $type = null, $length = null, $options = array(), $prepend = false) 986 998 { 987 999 if (is_string($options)) { … … 1028 1040 $this->_columnNames[$fieldName] = $name; 1029 1041 $this->_fieldNames[$name] = $fieldName; 1042 } 1043 1044 $defaultOptions = $this->getAttribute(Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS); 1045 1046 if (isset($defaultOptions['length']) && $defaultOptions['length'] && $length == null) { 1047 $length = $defaultOptions['length']; 1030 1048 } 1031 1049 … … 1054 1072 // YYYY-MM-DDTHH:MM:SS+00:00 ISO 8601 1055 1073 $length = 25; 1056 break;1057 1074 } 1058 1075 } … … 1060 1077 $options['type'] = $type; 1061 1078 $options['length'] = $length; 1079 1080 foreach ($defaultOptions as $key => $value) { 1081 if ( ! isset($options[$key]) || ! $options[$key]) { 1082 $options[$key] = $value; 1083 } 1084 } 1062 1085 1063 1086 if ($prepend) { -
branches/1.1/tests/run.php
r5029 r5030 54 54 $tickets->addTestCase(new Doctrine_Ticket_741_TestCase()); 55 55 $tickets->addTestCase(new Doctrine_Ticket_749_TestCase()); 56 $tickets->addTestCase(new Doctrine_Ticket_753_TestCase()); 56 57 $tickets->addTestCase(new Doctrine_Ticket_786_TestCase()); 57 58 $tickets->addTestCase(new Doctrine_Ticket_832_TestCase()); … … 148 149 $tickets->addTestCase(new Doctrine_Ticket_1465_TestCase()); 149 150 $tickets->addTestCase(new Doctrine_Ticket_1480_TestCase()); 150 $tickets->addTestCase(new Doctrine_Ticket_1483_TestCase());151 151 $tickets->addTestCase(new Doctrine_Ticket_1507_TestCase()); 152 152 $test->addTestCase($tickets); -
branches/1.1/UPGRADE_TO_1_1
r5027 r5030 43 43 $user->synchronizeWithArray($userArray); 44 44 $user->save(); 45 46 [r5027](http://trac.doctrine-project.org/changeset/5039) - Added support for setting default charset and collate for tables. 47 48 Set globally on a Doctrine_Manager instance. 49 50 $manager->setCollate('utf8_unicode_ci'); 51 $manager->setCharset('utf8'); 52 53 The same can be set on the Doctrine_Connection and Doctrine_Record levels. 54 55 $connection->setCollate('utf8_unicode_ci'); 56 $connection->setCharset('utf8'); 57 58 public function setTableDefinition() 59 { 60 $this->setCollate('utf8_unicode_ci'); 61 $this->setCharset('utf8'); 62 } 63 64 [r5030](http://trac.doctrine-project.org/changeset/5039) - Added support for setting default options for columns and auto added identifier columns. 65 66 The following is now possible on Doctrine_Manager, Doctrine_Connection and Doctrine_Record. 67 68 $manager->setAttribute(Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS, array('type' => 'string', 'length' => 255, 'notnull' => true)); 69 70 You can also customize the values that make up the auto added identifier column as well. 71 72 $manager->setAttribute(Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS, array('name' => '%s_id', 'type' => 'string', 'length' => 16)); // %s in the name is replaced with the table name.