I need to specify my own size fur floats (18,15) and cannot rely on the defaults (10,2).
Code: [Select]
The above code does not break anything as per my tests.
Before, only numeric type sizes were allowed. Now, the same is allowed within any number of commas.
/Sources/Class-DBPackages.php (working copy)
@@ -88,8 +88,16 @@
$default = '';
// Sort out the size... and stuff...
- $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
+ if (isset($column['size']))
+ {
+ $s = array_filter(explode(',', $column['size']), 'is_numeric');
+ if (!empty($s))
+ $column['size'] = implode(',', $s);
+ else
+ $column['size'] = null;
+ }
+
// Allow unsigned integers
$unsigned = in_array($column['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column['unsigned']) ? 'unsigned ' : '';
@@ -141,8 +149,16 @@
if (!isset($current_columns[$column['name']]))
{
// The column is new, add it to the list of columns to be added
- $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
+ if (isset($column['size']))
+ {
+ $s = array_filter(explode(',', $column['size']), 'is_numeric');
+ if (!empty($s))
+ $column['size'] = implode(',', $s);
+ else
+ $column['size'] = null;
+ }
+
// Allow unsigned integers
$unsigned = in_array($column['type'], $numeric_types) && !empty($column['unsigned']) ? 'unsigned ' : '';
@@ -160,8 +176,16 @@
else
{
// The column already exists, does it need changing?
- $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
+ if (isset($column['size']))
+ {
+ $s = array_filter(explode(',', $column['size']), 'is_numeric');
+ if (!empty($s))
+ $column['size'] = implode(',', $s);
+ else
+ $column['size'] = null;
+ }
+
// Allow unsigned integers
$unsigned = in_array($column['type'], $numeric_types) && !empty($column['unsigned']) ? 'unsigned ' : '';The above code does not break anything as per my tests.
Before, only numeric type sizes were allowed. Now, the same is allowed within any number of commas.
This topic was marked solved by 


