From: Andrey Kutejko Date: Thu, 25 Jul 2013 17:21:13 +0000 (+0300) Subject: fix building and exporting decimal type with scale X-Git-Tag: 0.6~83 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=d9482baab7a4314d668729c22562b0b61882286c;p=ipf-legacy-orm.git fix building and exporting decimal type with scale --- diff --git a/ipf/orm/datadict/mysql.php b/ipf/orm/datadict/mysql.php index 0041994..ddba725 100644 --- a/ipf/orm/datadict/mysql.php +++ b/ipf/orm/datadict/mysql.php @@ -172,8 +172,15 @@ class IPF_ORM_DataDict_Mysql extends IPF_ORM_DataDict case 'double': return 'DOUBLE'; case 'decimal': - $length = !empty($field['length']) ? $field['length'] : 18; $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(IPF_ORM::ATTR_DECIMAL_PLACES); + if (!empty($field['length'])) { + $length = $field['length']; + if (is_array($length)) { + list($length, $scale) = $length; + } + } else { + $length = 18; + } return 'DECIMAL('.$length.','.$scale.')'; case 'bit': return 'BIT'; diff --git a/ipf/orm/import/builder.php b/ipf/orm/import/builder.php index ee6f88a..3b34351 100644 --- a/ipf/orm/import/builder.php +++ b/ipf/orm/import/builder.php @@ -166,7 +166,10 @@ class IPF_ORM_Import_Builder $build = " ".'$this->hasColumn(\'' . $columnName . '\', \'' . $column['type'] . '\''; if ($column['length']) { - $build .= ', ' . $column['length']; + if (is_numeric($column['length'])) + $build .= ', ' . $column['length']; + else + $build .= ', array(' . $column['length'] . ')'; } else { $build .= ', null'; }