181 $columnName = $tokenizer->getCurrentToken()->text;
183 $tokenizer->nextToken();
184 $tokenizer->skipWhiteSpace();
185 $token = $tokenizer->getCurrentToken();
187 $columnType = $token->upper;
188 if (!self::checkType($columnType))
190 throw new NotSupportedException(
'column type expected but [' . $tokenizer->getCurrentToken()->text .
'] found. line: ' . $tokenizer->getCurrentToken()->line);
193 $column =
new self($columnName);
194 $column->type = $columnType;
196 $level = $token->level;
198 $columnDefinition =
'';
201 if ($token->level == $level && $token->text ===
',')
205 if ($token->level < $level && $token->text ===
')')
210 $columnDefinition .= $token->text;
212 if ($token->upper ===
'NOT')
214 $column->nullable =
false;
216 elseif ($token->upper ===
'DEFAULT')
218 $column->default =
false;
220 elseif ($token->upper ===
'UNSIGNED')
222 $column->unsigned =
true;
224 elseif ($token->upper ===
'PRECISION')
226 $column->typeAddition = $token->upper;
228 elseif ($token->upper ===
'VARYING')
230 $column->typeAddition = $token->upper;
232 elseif ($column->default ===
false)
236 $column->default = $token->text;
240 $token = $tokenizer->nextToken();
243 if ($lengthLevel == -1)
245 if ($token->text ===
'(')
247 if ($column->type ===
'ENUM')
249 $lengthLevel = $token->level;
252 $columnDefinition .= $token->text;
254 $token = $tokenizer->nextToken();
256 if ($token->level === $lengthLevel && $token->text ===
')')
263 $column->enum[] = trim($token->text,
"'");
267 $column->enum[] = trim($token->text,
'"');
273 $lengthLevel = $token->level;
276 $columnDefinition .= $token->text;
278 $token = $tokenizer->nextToken();
280 if ($token->level === $lengthLevel && $token->text ===
')')
287 if (!$column->length)
289 $column->length = (int)$token->text;
293 $column->precision = (int)$token->text;
307 $column->setBody($columnDefinition);