From 28e937b98197bf486a7c4a09379ab361ae25eb48 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 11 Apr 2007 18:35:15 +0000 Subject: [PATCH] fixes #298 --- lib/Doctrine/DataDict/Mysql.php | 10 +++++++--- lib/Doctrine/Import/Builder.php | 3 +++ lib/Doctrine/Import/Mysql.php | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/DataDict/Mysql.php b/lib/Doctrine/DataDict/Mysql.php index 9cc85b4af..7415393a8 100644 --- a/lib/Doctrine/DataDict/Mysql.php +++ b/lib/Doctrine/DataDict/Mysql.php @@ -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 diff --git a/lib/Doctrine/Import/Builder.php b/lib/Doctrine/Import/Builder.php index 64d9d9349..4647a2b66 100644 --- a/lib/Doctrine/Import/Builder.php +++ b/lib/Doctrine/Import/Builder.php @@ -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('; diff --git a/lib/Doctrine/Import/Mysql.php b/lib/Doctrine/Import/Mysql.php index 2006f46bb..7d4d7ed25 100644 --- a/lib/Doctrine/Import/Mysql.php +++ b/lib/Doctrine/Import/Mysql.php @@ -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'),