Commit 1430e8ba authored by Dries's avatar Dries

- Patch #346450 by Josh Waihi: length property should be ignored on non varchar and char fields.

parent b6a1fa72
......@@ -105,7 +105,7 @@ protected function createTableSql($name, $table) {
protected function createFieldSql($name, $spec) {
$sql = "`" . $name . "` " . $spec['mysql_type'];
if (isset($spec['length'])) {
if (in_array($spec['type'], array('varchar', 'char', 'text')) && isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
......
......@@ -147,7 +147,7 @@ protected function createFieldSql($name, $spec) {
$sql .= " CHECK ($name >= 0)";
}
if (!empty($spec['length'])) {
if (in_array($spec['type'], array('varchar', 'char', 'text')) && isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
......
......@@ -62,7 +62,7 @@
* specify '0' as the default value for a type 'int' field it
* will not work because '0' is a string containing the
* character "zero", not an integer.
* - 'length': The maximal length of a type 'varchar' or 'text'
* - 'length': The maximal length of a type 'char', 'varchar' or 'text'
* field. Ignored for other field types.
* - 'unsigned': A boolean indicating whether a type 'int', 'float'
* and 'numeric' only is signed or unsigned. Defaults to
......
......@@ -139,7 +139,7 @@ protected function createFieldSql($name, $spec) {
else {
$sql = $name . " " . $spec['sqlite_type'];
if (isset($spec['length'])) {
if (in_array($spec['type'], array('varchar', 'char', 'text')) && isset($spec['length'])) {
$sql .= '(' . $spec['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