From 417b71f4474687df20d49ca0acc945d9e44543c4 Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 28 Jun 2007 12:11:55 +0000 Subject: [PATCH] --- lib/Doctrine/Import/Builder.php | 4 ++-- lib/Doctrine/Import/Mssql.php | 7 +++++-- lib/Doctrine/Import/Mysql.php | 5 +++-- lib/Doctrine/Import/Oracle.php | 7 +++++-- lib/Doctrine/Import/Pgsql.php | 9 ++++++--- lib/Doctrine/Import/Sqlite.php | 7 ++++++- 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/Import/Builder.php b/lib/Doctrine/Import/Builder.php index 7bddac61d..05443235b 100644 --- a/lib/Doctrine/Import/Builder.php +++ b/lib/Doctrine/Import/Builder.php @@ -120,7 +120,7 @@ END; $i = 1; foreach ($tableColumns as $name => $column) { - $columns[$i] = ' $this->hasColumn(\'' . $name . '\', \'' . $column['ptype'][0] . '\''; + $columns[$i] = ' $this->hasColumn(\'' . $name . '\', \'' . $column['type'] . '\''; if ($column['length']) { $columns[$i] .= ', ' . $column['length']; } else { @@ -147,7 +147,7 @@ END; if (isset($column['unsigned']) && $column['unsigned']) { $a[] = '\'unsigned\' => true'; } - if ($column['ptype'][0] == 'enum' && isset($column['values']) && $column['values']) { + if ($column['type'] == 'enum' && isset($column['values']) && $column['values']) { $a[] = '\'values\' => array(' . implode(',', $column['values']) . ')'; } diff --git a/lib/Doctrine/Import/Mssql.php b/lib/Doctrine/Import/Mssql.php index dcde30bc5..06c6c33db 100644 --- a/lib/Doctrine/Import/Mssql.php +++ b/lib/Doctrine/Import/Mssql.php @@ -59,6 +59,8 @@ class Doctrine_Import_Mssql extends Doctrine_Import $columns = array(); foreach ($result as $key => $val) { + $val = array_change_key_case($val, CASE_LOWER); + if (strstr($val['type_name'], ' ')) { list($type, $identity) = explode(' ', $val['type_name']); } else { @@ -74,8 +76,9 @@ class Doctrine_Import_Mssql extends Doctrine_Import $description = array( 'name' => $val['column_name'], - 'type' => $type, - 'ptype' => $decl['type'], + 'ntype' => $type, + 'type' => $decl['type'][0], + 'alltypes' => $decl['type'], 'length' => $decl['length'], 'fixed' => $decl['fixed'], 'unsigned' => $decl['unsigned'], diff --git a/lib/Doctrine/Import/Mysql.php b/lib/Doctrine/Import/Mysql.php index cd7139859..366735fb8 100644 --- a/lib/Doctrine/Import/Mysql.php +++ b/lib/Doctrine/Import/Mysql.php @@ -124,8 +124,9 @@ class Doctrine_Import_Mysql extends Doctrine_Import $description = array( 'name' => $val['field'], - 'type' => $val['type'], - 'ptype' => $decl['type'], + 'type' => $decl['type'][0], + 'alltypes' => $decl['type'], + 'ntype' => $val['type'], 'length' => $decl['length'], 'fixed' => $decl['fixed'], 'unsigned' => $decl['unsigned'], diff --git a/lib/Doctrine/Import/Oracle.php b/lib/Doctrine/Import/Oracle.php index b044fe6ca..5073c4366 100644 --- a/lib/Doctrine/Import/Oracle.php +++ b/lib/Doctrine/Import/Oracle.php @@ -122,13 +122,16 @@ class Doctrine_Import_Oracle extends Doctrine_Import $result = $this->conn->fetchAssoc($sql); foreach($result as $val) { + $val = array_change_key_case($val, CASE_LOWER); $decl = $this->conn->dataDict->getPortableDeclaration($val); + $descr[$val['column_name']] = array( 'name' => $val['column_name'], 'notnull' => (bool) ($val['nullable'] === 'N'), - 'type' => $val['data_type'], - 'ptype' => $decl['type'], + 'ntype' => $val['data_type'], + 'type' => $decl['type'][0], + 'alltypes' => $decl['type'], 'fixed' => $decl['fixed'], 'unsigned' => $decl['unsigned'], 'default' => $val['data_default'], diff --git a/lib/Doctrine/Import/Pgsql.php b/lib/Doctrine/Import/Pgsql.php index eedb7a34a..870eda21f 100644 --- a/lib/Doctrine/Import/Pgsql.php +++ b/lib/Doctrine/Import/Pgsql.php @@ -154,7 +154,9 @@ class Doctrine_Import_Pgsql extends Doctrine_Import $columns = array(); foreach ($result as $key => $val) { - if ($val['type'] === 'varchar') { + $val = array_change_key_case($val, CASE_LOWER); + + if (strtolower($val['type']) === 'varchar') { // get length from varchar definition $length = preg_replace('~.*\(([0-9]*)\).*~', '$1', $val['complete_type']); $val['length'] = $length; @@ -164,8 +166,9 @@ class Doctrine_Import_Pgsql extends Doctrine_Import $description = array( 'name' => $val['field'], - 'type' => $val['type'], - 'ptype' => $decl['type'], + 'ntype' => $val['type'], + 'type' => $decl['type'][0], + 'alltypes' => $decl['type'], 'length' => $decl['length'], 'fixed' => $decl['fixed'], 'unsigned' => $decl['unsigned'], diff --git a/lib/Doctrine/Import/Sqlite.php b/lib/Doctrine/Import/Sqlite.php index da9d17c7b..ab4d275af 100644 --- a/lib/Doctrine/Import/Sqlite.php +++ b/lib/Doctrine/Import/Sqlite.php @@ -130,9 +130,14 @@ class Doctrine_Import_Sqlite extends Doctrine_Import $description = array(); $columns = array(); foreach ($result as $key => $val) { + $val = array_change_key_case($val, CASE_LOWER); + $decl = $this->conn->dataDict->getPortableDeclaration($val); + $description = array( 'name' => $val['name'], - 'type' => $val['type'], + 'ntype' => $val['type'], + 'type' => $decl['type'][0], + 'alltypes' => $decl['type'], 'notnull' => (bool) $val['notnull'], 'default' => $val['dflt_value'], 'primary' => (bool) $val['pk'],