Commit 28e937b9 authored by zYne's avatar zYne

fixes #298

parent dcab3087
......@@ -137,7 +137,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
if ( ! isset($field['type'])) {
$field['type'] = null;
}
switch ($field['type']) {
case 'char':
$length = (! empty($field['length'])) ? $field['length'] : false;
......@@ -246,6 +246,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
if ( ! isset($field['name'])) {
$field['name'] = '';
}
$values = null;
switch ($dbType) {
case 'tinyint':
......@@ -304,7 +306,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
}
break;
case 'enum':
$type[] = 'text';
$type[] = 'enum';
preg_match_all('/\'.+\'/U', $field['type'], $matches);
$length = 0;
$fixed = false;
......@@ -317,6 +319,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
} else {
$values = $matches[0];
}
}
$type[] = 'integer';
......@@ -369,7 +373,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
$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
......
......@@ -121,6 +121,9 @@ class Doctrine_Import_Builder
if (isset($column['unsigned']) && $column['unsigned']) {
$a[] = '\'unsigned\' => true';
}
if ($column['ptype'][0] == 'enum' && isset($column['values']) && $column['values']) {
$a[] = '\'values\' => array(' . implode(',', $column['values']) . ')';
}
if ( ! empty($a)) {
$columns[$i] .= ', ' . 'array(';
......
......@@ -129,6 +129,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
'length' => $decl['length'],
'fixed' => $decl['fixed'],
'unsigned' => $decl['unsigned'],
'values' => $decl['values'],
'primary' => (strtolower($val['key']) == 'pri'),
'default' => $val['default'],
'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