1
0
mirror of synced 2024-12-13 22:56:04 +03:00

enhanced error handling

This commit is contained in:
zYne 2007-04-18 11:11:07 +00:00
parent 26a723e81d
commit b71ac561c3
7 changed files with 30 additions and 12 deletions

View File

@ -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':
@ -91,9 +94,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']);
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
/**
* Maps a native array description of a field to a Doctrine datatype and length

View File

@ -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'] . '\'.');
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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