From c38137d551c87d61c7d072f540237c485c5356b9 Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 4 Feb 2007 22:34:44 +0000 Subject: [PATCH] int alias added --- lib/Doctrine/DataDict/Firebird.php | 4 +++- lib/Doctrine/DataDict/Mssql.php | 5 +++-- lib/Doctrine/DataDict/Oracle.php | 9 ++++++--- lib/Doctrine/DataDict/Pgsql.php | 1 + lib/Doctrine/DataDict/Sqlite.php | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/DataDict/Firebird.php b/lib/Doctrine/DataDict/Firebird.php index b3522016e..c882309a9 100644 --- a/lib/Doctrine/DataDict/Firebird.php +++ b/lib/Doctrine/DataDict/Firebird.php @@ -75,6 +75,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict return 'BLOB SUB_TYPE 0'; case 'integer': case 'enum': + case 'int': return 'INT'; case 'boolean': return 'SMALLINT'; @@ -89,8 +90,9 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; return 'DECIMAL('.$length.','.$this->conn->options['decimal_places'].')'; + default: + throw new Doctrine_DataDict_Exception('Unknown field type '. $field['type']); } - return ''; } /** * Maps a native array description of a field to a Doctrine datatype and length diff --git a/lib/Doctrine/DataDict/Mssql.php b/lib/Doctrine/DataDict/Mssql.php index 7af719899..c4bf35f5a 100644 --- a/lib/Doctrine/DataDict/Mssql.php +++ b/lib/Doctrine/DataDict/Mssql.php @@ -90,6 +90,7 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict return 'IMAGE'; case 'integer': case 'enum': + case 'int': return 'INT'; case 'boolean': return 'BIT'; @@ -105,7 +106,7 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict $length = !empty($field['length']) ? $field['length'] : 18; return 'DECIMAL('.$length.','.$this->conn->options['decimal_places'].')'; } - return ''; + throw new Doctrine_DataDict_Exception('Unknown column type.'); } /** * Maps a native array description of a field to a MDB2 datatype and length @@ -172,7 +173,7 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict default: throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$db_type); } - + return array($type, $length, $unsigned, $fixed); } } diff --git a/lib/Doctrine/DataDict/Oracle.php b/lib/Doctrine/DataDict/Oracle.php index 22054ec9b..fa68c5a7f 100644 --- a/lib/Doctrine/DataDict/Oracle.php +++ b/lib/Doctrine/DataDict/Oracle.php @@ -72,6 +72,7 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict return 'BLOB'; case 'integer': case 'enum': + case 'int': if (!empty($field['length'])) { return 'NUMBER('.$field['length'].')'; } @@ -86,6 +87,8 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict return 'NUMBER'; case 'decimal': return 'NUMBER(*,'.$this->conn->options['decimal_places'].')'; + default: + throw new Doctrine_DataDict_Exception('Unknown field type '. $field['type']); } } /** @@ -97,7 +100,7 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict */ public function getPortableDeclaration(array $field) { - $db_type = strtolower($field['type']); + $dbType = strtolower($field['type']); $type = array(); $length = $unsigned = $fixed = null; if (!empty($field['length'])) { @@ -108,7 +111,7 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict $field['name'] = ''; } - switch ($db_type) { + switch ($dbType) { case 'integer': case 'pls_integer': case 'binary_integer': @@ -174,7 +177,7 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict case 'rowid': case 'urowid': default: - throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$db_type); + throw new Doctrine_DataDict_Exception('unknown database attribute type: ' . $dbType); } return array($type, $length, $unsigned, $fixed); diff --git a/lib/Doctrine/DataDict/Pgsql.php b/lib/Doctrine/DataDict/Pgsql.php index 4ff2ff19b..347566b54 100644 --- a/lib/Doctrine/DataDict/Pgsql.php +++ b/lib/Doctrine/DataDict/Pgsql.php @@ -378,6 +378,7 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict return 'BYTEA'; case 'enum': case 'integer': + case 'int': if (!empty($field['autoincrement'])) { if (!empty($field['length'])) { $length = $field['length']; diff --git a/lib/Doctrine/DataDict/Sqlite.php b/lib/Doctrine/DataDict/Sqlite.php index 669c854ff..658f6aa29 100644 --- a/lib/Doctrine/DataDict/Sqlite.php +++ b/lib/Doctrine/DataDict/Sqlite.php @@ -97,6 +97,7 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict case 'enum': case 'integer': case 'boolean': + case 'int': return 'INTEGER'; case 'date': return 'DATE';