]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
fix building and exporting decimal type with scale
authorAndrey Kutejko <andy128k@gmail.com>
Thu, 25 Jul 2013 17:21:13 +0000 (20:21 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Thu, 25 Jul 2013 17:21:13 +0000 (20:21 +0300)
ipf/orm/datadict/mysql.php
ipf/orm/import/builder.php

index 0041994337dc8ebe2ea5934ec5bb0e8dad746973..ddba725bea2e2f995bcc30083ac16d208668b050 100644 (file)
@@ -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';
index ee6f88a31320c50395fbbfb61639ec3bd9e56080..3b34351604020690d1d5f5d5c9e89a02942d77f0 100644 (file)
@@ -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';
             }