Commit b71ac561 authored by zYne's avatar zYne

enhanced error handling

parent 26a723e8
......@@ -57,6 +57,9 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
*/
public function getNativeDeclaration($field)
{
if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.');
}
switch ($field['type']) {
case 'varchar':
case 'string':
......@@ -90,10 +93,10 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
return 'DOUBLE PRECISION';
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 'DECIMAL(' . $length.',' . $this->conn->options['decimal_places'] . ')';
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
/**
* Maps a native array description of a field to a Doctrine datatype and length
......
......@@ -56,6 +56,9 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict
*/
public function getNativeDeclaration($field)
{
if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.');
}
switch ($field['type']) {
case 'char':
case 'varchar':
......@@ -102,6 +105,6 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict
case 'decimal':
return 'DECIMAL';
}
return '';
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
}
......@@ -59,6 +59,9 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
*/
public function getNativeDeclaration($field)
{
if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.');
}
switch ($field['type']) {
case 'array':
case 'object':
......@@ -107,7 +110,8 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
$length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$this->conn->options['decimal_places'].')';
}
throw new Doctrine_DataDict_Exception('Unknown column type.');
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
/**
* Maps a native array description of a field to a MDB2 datatype and length
......
......@@ -135,7 +135,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
public function getNativeDeclaration($field)
{
if ( ! isset($field['type'])) {
$field['type'] = null;
throw new Doctrine_DataDict_Exception('Missing column type.');
}
switch ($field['type']) {
......@@ -218,7 +218,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
$length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL(' . $length . ',' . 0 . ')'; //$this->dbh->options['decimal_places'] . ')';
}
throw new Doctrine_DataDict_Exception('Unknown column type ' . $field['type'] . '.');
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
/**
* Maps a native array description of a field to a MDB2 datatype and length
......@@ -367,7 +367,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
$length = null;
break;
default:
throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$dbType);
throw new Doctrine_DataDict_Exception('unknown database attribute type: ' . $dbType);
}
$length = ((int) $length == 0) ? null : (int) $length;
......
......@@ -55,6 +55,9 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
*/
public function getNativeDeclaration(array $field)
{
if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.');
}
switch ($field['type']) {
case 'string':
case 'array':
......@@ -91,8 +94,8 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
case 'decimal':
return 'NUMBER(*,'.$this->conn->options['decimal_places'].')';
default:
throw new Doctrine_DataDict_Exception('Unknown field type '. $field['type']);
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
/**
* Maps a native array description of a field to a doctrine datatype and length
......
......@@ -360,6 +360,9 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
*/
public function getNativeDeclaration(array $field)
{
if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.');
}
switch ($field['type']) {
case 'char':
case 'string':
......@@ -415,9 +418,8 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18;
return 'NUMERIC(' . $length . ',' . $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES) . ')';
default:
throw new Doctrine_DataDict_Exception('Unknown field type '. $field['type']);
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
/**
* Maps a native array description of a field to a portable Doctrine datatype and length
......
......@@ -57,6 +57,9 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
*/
public function getNativeDeclaration(array $field)
{
if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.');
}
switch ($field['type']) {
case 'text':
case 'object':
......@@ -114,7 +117,7 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
$length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')';
}
throw new Doctrine_DataDict_Exception('Unknown datatype ' . $field['type']);
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
/**
* Maps a native array description of a field to Doctrine datatype and length
......
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