Commit d9d4e877 authored by zYne's avatar zYne

Fixed many small bugs

parent 1febda11
......@@ -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'])) {
......
......@@ -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);
}
}
......@@ -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);
}
/**
......
......@@ -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';
......
......@@ -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'])) {
......
......@@ -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';
......
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