|
19 | 19 |
|
20 | 20 | namespace Doctrine\DBAL\Platforms;
|
21 | 21 |
|
22 |
| -use Doctrine\DBAL\DBALException; |
| 22 | +use Doctrine\Common\EventManager; |
23 | 23 | use Doctrine\DBAL\Connection;
|
24 |
| -use Doctrine\DBAL\Schema\Identifier; |
25 |
| -use Doctrine\DBAL\Types; |
| 24 | +use Doctrine\DBAL\DBALException; |
| 25 | +use Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs; |
| 26 | +use Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs; |
| 27 | +use Doctrine\DBAL\Event\SchemaAlterTableEventArgs; |
| 28 | +use Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs; |
| 29 | +use Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs; |
| 30 | +use Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs; |
| 31 | +use Doctrine\DBAL\Event\SchemaCreateTableEventArgs; |
| 32 | +use Doctrine\DBAL\Event\SchemaDropTableEventArgs; |
| 33 | +use Doctrine\DBAL\Events; |
| 34 | +use Doctrine\DBAL\Schema\Column; |
| 35 | +use Doctrine\DBAL\Schema\ColumnDiff; |
26 | 36 | use Doctrine\DBAL\Schema\Constraint;
|
| 37 | +use Doctrine\DBAL\Schema\ForeignKeyConstraint; |
| 38 | +use Doctrine\DBAL\Schema\Identifier; |
| 39 | +use Doctrine\DBAL\Schema\Index; |
27 | 40 | use Doctrine\DBAL\Schema\Sequence;
|
28 | 41 | use Doctrine\DBAL\Schema\Table;
|
29 |
| -use Doctrine\DBAL\Schema\Index; |
30 |
| -use Doctrine\DBAL\Schema\ForeignKeyConstraint; |
31 | 42 | use Doctrine\DBAL\Schema\TableDiff;
|
32 |
| -use Doctrine\DBAL\Schema\Column; |
33 |
| -use Doctrine\DBAL\Schema\ColumnDiff; |
| 43 | +use Doctrine\DBAL\Types; |
34 | 44 | use Doctrine\DBAL\Types\Type;
|
35 |
| -use Doctrine\DBAL\Events; |
36 |
| -use Doctrine\Common\EventManager; |
37 |
| -use Doctrine\DBAL\Event\SchemaCreateTableEventArgs; |
38 |
| -use Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs; |
39 |
| -use Doctrine\DBAL\Event\SchemaDropTableEventArgs; |
40 |
| -use Doctrine\DBAL\Event\SchemaAlterTableEventArgs; |
41 |
| -use Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs; |
42 |
| -use Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs; |
43 |
| -use Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs; |
44 |
| -use Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs; |
45 | 45 |
|
46 | 46 | /**
|
47 | 47 | * Base class for all DatabasePlatforms. The DatabasePlatforms are the central
|
@@ -1556,7 +1556,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
|
1556 | 1556 | $columnData['version'] = $column->hasPlatformOption("version") ? $column->getPlatformOption('version') : false;
|
1557 | 1557 | $columnData['comment'] = $this->getColumnComment($column);
|
1558 | 1558 |
|
1559 |
| - if (strtolower($columnData['type']) == "string" && $columnData['length'] === null) { |
| 1559 | + if ($columnData['type'] instanceof Types\StringType && $columnData['length'] === null) { |
1560 | 1560 | $columnData['length'] = 255;
|
1561 | 1561 | }
|
1562 | 1562 |
|
@@ -2279,15 +2279,20 @@ public function getDefaultValueDeclarationSQL($field)
|
2279 | 2279 | if (isset($field['default'])) {
|
2280 | 2280 | $default = " DEFAULT '".$field['default']."'";
|
2281 | 2281 | if (isset($field['type'])) {
|
2282 |
| - if (in_array((string) $field['type'], ["Integer", "BigInt", "SmallInt"])) { |
| 2282 | + $type = $field['type']; |
| 2283 | + if ($type instanceof Types\IntegerType || |
| 2284 | + $type instanceof Types\BigIntType || |
| 2285 | + $type instanceof Types\SmallIntType |
| 2286 | + ) { |
2283 | 2287 | $default = " DEFAULT ".$field['default'];
|
2284 |
| - } elseif (in_array((string) $field['type'], ['DateTime', 'DateTimeTz']) && $field['default'] == $this->getCurrentTimestampSQL()) { |
| 2288 | + } elseif (($type instanceof Types\DateTimeType || $type instanceof Types\DateTimeTzType) |
| 2289 | + && $field['default'] == $this->getCurrentTimestampSQL()) { |
2285 | 2290 | $default = " DEFAULT ".$this->getCurrentTimestampSQL();
|
2286 |
| - } elseif ((string) $field['type'] == 'Time' && $field['default'] == $this->getCurrentTimeSQL()) { |
| 2291 | + } elseif ($type instanceof Types\TimeType && $field['default'] == $this->getCurrentTimeSQL()) { |
2287 | 2292 | $default = " DEFAULT ".$this->getCurrentTimeSQL();
|
2288 |
| - } elseif ((string) $field['type'] == 'Date' && $field['default'] == $this->getCurrentDateSQL()) { |
2289 |
| - $default = " DEFAULT ".$this->getCurrentDateSQL(); |
2290 |
| - } elseif ((string) $field['type'] == 'Boolean') { |
| 2293 | + } elseif ($type instanceof Types\DateType && $field['default'] == $this->getCurrentDateSQL()) { |
| 2294 | + $default = " DEFAULT ".$this>getCurrentDateSQL(); |
| 2295 | + } elseif ($type instanceof Types\BooleanType) { |
2291 | 2296 | $default = " DEFAULT '" . $this->convertBooleans($field['default']) . "'";
|
2292 | 2297 | }
|
2293 | 2298 | }
|
|
0 commit comments