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

- added ability to set scale at runtime

This commit is contained in:
lsmith 2007-05-11 19:20:38 +00:00
parent fd0c11073c
commit ad0f389870
6 changed files with 15 additions and 9 deletions

View File

@ -93,7 +93,8 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
return 'DOUBLE PRECISION';
case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')';
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'DECIMAL('.$length.','.$scale.')';
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');

View File

@ -108,7 +108,8 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
return 'FLOAT';
case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')';
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'DECIMAL('.$length.','.$scale.')';
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');

View File

@ -216,7 +216,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
return 'DOUBLE';
case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')';
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'DECIMAL('.$length.','.$scale.')';
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}

View File

@ -92,7 +92,8 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
case 'double':
return 'NUMBER';
case 'decimal':
return 'NUMBER(*,'.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')';
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'NUMBER(*,'.$scale.')';
default:
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');

View File

@ -417,7 +417,8 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
return 'FLOAT8';
case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18;
return 'NUMERIC(' . $length . ',' . $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES) . ')';
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'NUMERIC('.$length.','.$scale.')';
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
@ -548,7 +549,7 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
return array('type' => $type,
'length' => $length,
'unsigned' => $unsigned,
'unsigned' => $unsigned,
'fixed' => $fixed);
}
/**
@ -606,7 +607,7 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
}
/**
* parseBoolean
* parses a literal boolean value and returns
* parses a literal boolean value and returns
* proper sql equivalent
*
* @param string $value boolean value to be parsed

View File

@ -115,7 +115,8 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
//($this->conn->options['fixed_float']+2).','.$this->conn->options['fixed_float'].')' : '');
case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')';
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'DECIMAL('.$length.','.$scale.')';
}
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.');
}
@ -237,7 +238,7 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
return array('type' => $type,
'length' => $length,
'unsigned' => $unsigned,
'unsigned' => $unsigned,
'fixed' => $fixed);
}
/**