Skip to content

Commit 27324cd

Browse files
author
Phil Sturgeon
committed
Use arrays in DBForge for constraint for things like decimal, float, numeric, enum and set.
1 parent 5c56180 commit 27324cd

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

system/database/drivers/mysql/mysql_forge.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,26 @@ function _process_fields($fields)
8787
if (array_key_exists('TYPE', $attributes))
8888
{
8989
$sql .= ' '.$attributes['TYPE'];
90-
}
9190

92-
if (array_key_exists('CONSTRAINT', $attributes))
93-
{
94-
$sql .= '('.$attributes['CONSTRAINT'].')';
91+
if (array_key_exists('CONSTRAINT', $attributes))
92+
{
93+
switch ($attributes['TYPE'])
94+
{
95+
case 'decimal':
96+
case 'float':
97+
case 'numeric':
98+
$sql .= '('.implode(',', $attributes['CONSTRAINT']).')';
99+
break;
100+
101+
case 'enum':
102+
case 'set':
103+
$sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
104+
break;
105+
106+
default:
107+
$sql .= '('.$attributes['CONSTRAINT'].')';
108+
}
109+
}
95110
}
96111

97112
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)

0 commit comments

Comments
 (0)