Changeset 5123
- Timestamp:
- 10/21/08 23:07:34 (9 months ago)
- Location:
- branches
- Files:
-
- 8 modified
-
1.0/lib/Doctrine/DataDict/Mysql.php (modified) (4 diffs)
-
1.0/lib/Doctrine/Export/Schema.php (modified) (1 diff)
-
1.0/lib/Doctrine/Import/Mysql.php (modified) (1 diff)
-
1.0/lib/Doctrine/Import/Schema.php (modified) (1 diff)
-
1.1/lib/Doctrine/DataDict/Mysql.php (modified) (4 diffs)
-
1.1/lib/Doctrine/Export/Schema.php (modified) (1 diff)
-
1.1/lib/Doctrine/Import/Mysql.php (modified) (1 diff)
-
1.1/lib/Doctrine/Import/Schema.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/lib/Doctrine/DataDict/Mysql.php
r4858 r5123 251 251 } else { 252 252 $length = strtok('(), '); 253 $decimal = strtok('(), ') ;253 $decimal = strtok('(), ') ? strtok('(), '):null; 254 254 } 255 255 $type = array(); … … 261 261 262 262 $values = null; 263 $scale = null; 263 264 264 265 switch ($dbType) { … … 365 366 case 'unknown': 366 367 case 'decimal': 368 if ($decimal !== null) { 369 $scale = $decimal; 370 } 367 371 case 'numeric': 368 372 $type[] = 'decimal'; … … 404 408 405 409 $length = ((int) $length == 0) ? null : (int) $length; 406 407 if ($values === null) { 408 return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); 409 } else { 410 return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed, 'values' => $values); 411 } 410 $def = array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); 411 if ($values !== null) { 412 $def['values'] = $values; 413 } 414 if ($scale !== null) { 415 $def['scale'] = $scale; 416 } 417 return $def; 412 418 } 413 419 -
branches/1.0/lib/Doctrine/Export/Schema.php
r4196 r5123 73 73 // Fix explicit length in schema, concat it to type in this format: type(length) 74 74 foreach ($data['columns'] AS $name => $column) { 75 $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; 76 unset($data['columns'][$name]['length']); 77 75 if (isset($column['length']) && $column['length'] && isset($column['scale']) && $column['scale']) { 76 $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ', ' . $column['scale'] . ')'; 77 unset($data['columns'][$name]['length'], $data['columns'][$name]['scale']); 78 } else { 79 $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; 80 unset($data['columns'][$name]['length']); 81 } 78 82 // Strip out schema information which is not necessary to be dumped to the yaml schema file 79 83 foreach ($remove as $value) { -
branches/1.0/lib/Doctrine/Import/Mysql.php
r5026 r5123 168 168 'autoincrement' => (bool) (strpos($val['extra'], 'auto_increment') !== false), 169 169 ); 170 if (isset($decl['scale'])) { 171 $description['scale'] = $decl['scale']; 172 } 170 173 $columns[$val['field']] = $description; 171 174 } -
branches/1.0/lib/Doctrine/Import/Schema.php
r5118 r5123 378 378 if (isset($e[0]) && isset($e[1])) { 379 379 $colDesc['type'] = $e[0]; 380 $colDesc['length'] = substr($e[1], 0, strlen($e[1]) - 1); 380 $value = substr($e[1], 0, strlen($e[1]) - 1); 381 $e = explode(',', $value); 382 $colDesc['length'] = $e[0]; 383 if (isset($e[1]) && $e[1]) { 384 $colDesc['scale'] = $e[1]; 385 } 381 386 } else { 382 387 $colDesc['type'] = isset($field['type']) ? (string) $field['type']:null; -
branches/1.1/lib/Doctrine/DataDict/Mysql.php
r4858 r5123 251 251 } else { 252 252 $length = strtok('(), '); 253 $decimal = strtok('(), ') ;253 $decimal = strtok('(), ') ? strtok('(), '):null; 254 254 } 255 255 $type = array(); … … 261 261 262 262 $values = null; 263 $scale = null; 263 264 264 265 switch ($dbType) { … … 365 366 case 'unknown': 366 367 case 'decimal': 368 if ($decimal !== null) { 369 $scale = $decimal; 370 } 367 371 case 'numeric': 368 372 $type[] = 'decimal'; … … 404 408 405 409 $length = ((int) $length == 0) ? null : (int) $length; 406 407 if ($values === null) { 408 return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); 409 } else { 410 return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed, 'values' => $values); 411 } 410 $def = array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); 411 if ($values !== null) { 412 $def['values'] = $values; 413 } 414 if ($scale !== null) { 415 $def['scale'] = $scale; 416 } 417 return $def; 412 418 } 413 419 -
branches/1.1/lib/Doctrine/Export/Schema.php
r4196 r5123 73 73 // Fix explicit length in schema, concat it to type in this format: type(length) 74 74 foreach ($data['columns'] AS $name => $column) { 75 $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; 76 unset($data['columns'][$name]['length']); 77 75 if (isset($column['length']) && $column['length'] && isset($column['scale']) && $column['scale']) { 76 $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ', ' . $column['scale'] . ')'; 77 unset($data['columns'][$name]['length'], $data['columns'][$name]['scale']); 78 } else { 79 $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; 80 unset($data['columns'][$name]['length']); 81 } 78 82 // Strip out schema information which is not necessary to be dumped to the yaml schema file 79 83 foreach ($remove as $value) { -
branches/1.1/lib/Doctrine/Import/Mysql.php
r5026 r5123 168 168 'autoincrement' => (bool) (strpos($val['extra'], 'auto_increment') !== false), 169 169 ); 170 if (isset($decl['scale'])) { 171 $description['scale'] = $decl['scale']; 172 } 170 173 $columns[$val['field']] = $description; 171 174 } -
branches/1.1/lib/Doctrine/Import/Schema.php
r5118 r5123 378 378 if (isset($e[0]) && isset($e[1])) { 379 379 $colDesc['type'] = $e[0]; 380 $colDesc['length'] = substr($e[1], 0, strlen($e[1]) - 1); 380 $value = substr($e[1], 0, strlen($e[1]) - 1); 381 $e = explode(',', $value); 382 $colDesc['length'] = $e[0]; 383 if (isset($e[1]) && $e[1]) { 384 $colDesc['scale'] = $e[1]; 385 } 381 386 } else { 382 387 $colDesc['type'] = isset($field['type']) ? (string) $field['type']:null;