From 858177bc229261f336b01ea5b882f86aceda9c6c Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Thu, 25 Jul 2013 20:21:13 +0300 Subject: [PATCH] fix building and exporting decimal type with scale --- ipf/orm/datadict/mysql.php | 9 ++++++++- ipf/orm/import/builder.php | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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'; } -- 2.49.0