diff --git a/lib/Doctrine/DataDict/Firebird.php b/lib/Doctrine/DataDict/Firebird.php index c79ba34b0..7200904b9 100644 --- a/lib/Doctrine/DataDict/Firebird.php +++ b/lib/Doctrine/DataDict/Firebird.php @@ -100,16 +100,16 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict */ public function getPortableDeclaration($field) { - $length = $field['length']; - - if ((int) $length <= 0) - $length = null; + $length = (isset($field['length']) && $field['length'] > 0) ? $field['length'] : null; $type = array(); $unsigned = $fixed = null; $dbType = strtolower($field['type']); $field['field_sub_type'] = !empty($field['field_sub_type']) ? strtolower($field['field_sub_type']) : null; + + if( ! isset($field['name'])) + $field['name'] = ''; switch ($dbType) { case 'smallint': @@ -134,7 +134,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict $fixed = false; case 'char': case 'cstring': - $type[] = 'text'; + $type[] = 'string'; if ($length == '1') { $type[] = 'boolean'; if (preg_match('/^(is|has)/', $field['name'])) { diff --git a/lib/Doctrine/DataDict/Mssql.php b/lib/Doctrine/DataDict/Mssql.php index 528c9dde7..e4720baef 100644 --- a/lib/Doctrine/DataDict/Mssql.php +++ b/lib/Doctrine/DataDict/Mssql.php @@ -116,19 +116,24 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict public function getPortableDeclaration($field) { $db_type = preg_replace('/\d/','', strtolower($field['type']) ); - $length = $field['length']; - if ((int)$length <= 0) { - $length = null; - } + $length = (isset($field['length']) && $field['length'] > 0) ? $field['length'] : null; + $type = array(); // todo: unsigned handling seems to be missing $unsigned = $fixed = null; + + if( ! isset($field['name'])) + $field['name'] = ''; + switch ($db_type) { case 'bit': $type[0] = 'boolean'; break; case 'int': $type[0] = 'integer'; + if($length == 1) { + $type[] = 'boolean'; + } break; case 'datetime': $type[0] = 'timestamp'; @@ -146,7 +151,7 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict case 'varchar': $fixed = false; case 'char': - $type[0] = 'text'; + $type[0] = 'string'; if ($length == '1') { $type[] = 'boolean'; if (preg_match('/^[is|has]/', $field['name'])) { @@ -168,6 +173,8 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict throw new Doctrine_DataDict_Mssql_Exception('unknown database attribute type: '.$db_type); } + + return array($type, $length, $unsigned, $fixed); } } diff --git a/lib/Doctrine/DataDict/Mysql.php b/lib/Doctrine/DataDict/Mysql.php index 89c88796a..4f067a70a 100644 --- a/lib/Doctrine/DataDict/Mysql.php +++ b/lib/Doctrine/DataDict/Mysql.php @@ -226,7 +226,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict if ($dbType == 'national') { $dbType = strtok('(), '); } - if (!empty($field['length'])) { + if (isset($field['length'])) { $length = $field['length']; $decimal = ''; } else { @@ -235,6 +235,10 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict } $type = array(); $unsigned = $fixed = null; + + if( ! isset($field['name'])) + $field['name'] = ''; + switch ($dbType) { case 'tinyint': $type[] = 'integer'; @@ -275,7 +279,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict $fixed = false; case 'string': case 'char': - $type[] = 'text'; + $type[] = 'string'; if ($length == '1') { $type[] = 'boolean'; if (preg_match('/^(is|has)/', $field['name'])) { @@ -354,6 +358,9 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict throw new Doctrine_DataDict_Mysql_Exception('unknown database attribute type: '.$dbType); } + $length = ((int) $length == 0) ? null : (int) $length; + + return array($type, $length, $unsigned, $fixed); } /** diff --git a/lib/Doctrine/DataDict/Oracle.php b/lib/Doctrine/DataDict/Oracle.php index 979089ce7..fa18ba297 100644 --- a/lib/Doctrine/DataDict/Oracle.php +++ b/lib/Doctrine/DataDict/Oracle.php @@ -103,6 +103,10 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict if (!empty($field['length'])) { $length = $field['length']; } + + if( ! isset($field['name'])) + $field['name'] = ''; + switch ($db_type) { case 'integer': case 'pls_integer': @@ -121,7 +125,7 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict $fixed = false; case 'char': case 'nchar': - $type[] = 'text'; + $type[] = 'string'; if ($length == '1') { $type[] = 'boolean'; if (preg_match('/^(is|has)/', $field['name'])) { @@ -154,7 +158,7 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict } break; case 'long': - $type[] = 'text'; + $type[] = 'string'; case 'clob': case 'nclob': $type[] = 'clob'; diff --git a/lib/Doctrine/DataDict/Pgsql.php b/lib/Doctrine/DataDict/Pgsql.php index 0a0172ef2..67ec1d801 100644 --- a/lib/Doctrine/DataDict/Pgsql.php +++ b/lib/Doctrine/DataDict/Pgsql.php @@ -425,7 +425,7 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict public function getPortableDeclaration(array $field) { - $length = $field['length']; + $length = (isset($field['length'])) ? $field['length'] : null; if ($length == '-1' && isset($field['atttypmod'])) { $length = $field['atttypmod'] - 4; } @@ -434,7 +434,13 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict } $type = array(); $unsigned = $fixed = null; - switch (strtolower($field['type'])) { + + if( ! isset($field['name'])) + $field['name'] = ''; + + $db_type = strtolower($field['type']); + + switch ($db_type) { case 'smallint': case 'int2': $type[] = 'integer'; @@ -475,7 +481,7 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict case 'unknown': case 'char': case 'bpchar': - $type[] = 'text'; + $type[] = 'string'; if ($length == '1') { $type[] = 'boolean'; if (preg_match('/^(is|has)/', $field['name'])) { diff --git a/lib/Doctrine/DataDict/Sqlite.php b/lib/Doctrine/DataDict/Sqlite.php index 072f5e9ff..d58898a44 100644 --- a/lib/Doctrine/DataDict/Sqlite.php +++ b/lib/Doctrine/DataDict/Sqlite.php @@ -123,10 +123,14 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict public function getPortableDeclaration(array $field) { $dbType = strtolower($field['type']); - $length = ( ! empty($field['length'])) ? $field['length'] : null; - $unsigned = ( ! empty($field['unsigned'])) ? $field['unsigned'] : null; + $length = (isset($field['length'])) ? $field['length'] : null; + $unsigned = (isset($field['unsigned'])) ? $field['unsigned'] : null; $fixed = null; $type = array(); + + if( ! isset($field['name'])) + $field['name'] = ''; + switch ($dbType) { case 'boolean': $type[] = 'boolean';