Commit 28e937b9 authored by zYne's avatar zYne

fixes #298

parent dcab3087
...@@ -137,7 +137,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict ...@@ -137,7 +137,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
$field['type'] = null; $field['type'] = null;
} }
switch ($field['type']) { switch ($field['type']) {
case 'char': case 'char':
$length = (! empty($field['length'])) ? $field['length'] : false; $length = (! empty($field['length'])) ? $field['length'] : false;
...@@ -246,6 +246,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict ...@@ -246,6 +246,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
if ( ! isset($field['name'])) { if ( ! isset($field['name'])) {
$field['name'] = ''; $field['name'] = '';
} }
$values = null;
switch ($dbType) { switch ($dbType) {
case 'tinyint': case 'tinyint':
...@@ -304,7 +306,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict ...@@ -304,7 +306,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
} }
break; break;
case 'enum': case 'enum':
$type[] = 'text'; $type[] = 'enum';
preg_match_all('/\'.+\'/U', $field['type'], $matches); preg_match_all('/\'.+\'/U', $field['type'], $matches);
$length = 0; $length = 0;
$fixed = false; $fixed = false;
...@@ -317,6 +319,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict ...@@ -317,6 +319,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
if (preg_match('/^(is|has)/', $field['name'])) { if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
} }
} else {
$values = $matches[0];
} }
} }
$type[] = 'integer'; $type[] = 'integer';
...@@ -369,7 +373,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict ...@@ -369,7 +373,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
$length = ((int) $length == 0) ? null : (int) $length; $length = ((int) $length == 0) ? null : (int) $length;
return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed, 'values' => $values);
} }
/** /**
* Obtain DBMS specific SQL code portion needed to set the CHARACTER SET * Obtain DBMS specific SQL code portion needed to set the CHARACTER SET
......
...@@ -121,6 +121,9 @@ class Doctrine_Import_Builder ...@@ -121,6 +121,9 @@ class Doctrine_Import_Builder
if (isset($column['unsigned']) && $column['unsigned']) { if (isset($column['unsigned']) && $column['unsigned']) {
$a[] = '\'unsigned\' => true'; $a[] = '\'unsigned\' => true';
} }
if ($column['ptype'][0] == 'enum' && isset($column['values']) && $column['values']) {
$a[] = '\'values\' => array(' . implode(',', $column['values']) . ')';
}
if ( ! empty($a)) { if ( ! empty($a)) {
$columns[$i] .= ', ' . 'array('; $columns[$i] .= ', ' . 'array(';
......
...@@ -129,6 +129,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import ...@@ -129,6 +129,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
'length' => $decl['length'], 'length' => $decl['length'],
'fixed' => $decl['fixed'], 'fixed' => $decl['fixed'],
'unsigned' => $decl['unsigned'], 'unsigned' => $decl['unsigned'],
'values' => $decl['values'],
'primary' => (strtolower($val['key']) == 'pri'), 'primary' => (strtolower($val['key']) == 'pri'),
'default' => $val['default'], 'default' => $val['default'],
'notnull' => (bool) ($val['null'] != 'YES'), 'notnull' => (bool) ($val['null'] != 'YES'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment