Added type hints to the Column class

parent d4d94013
This diff is collapsed.
...@@ -47,12 +47,9 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -47,12 +47,9 @@ class DB2SchemaManager extends AbstractSchemaManager
{ {
$tableColumn = array_change_key_case($tableColumn, CASE_LOWER); $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
$length = null; $length = $precision = $default = null;
$fixed = null; $scale = 0;
$scale = false; $fixed = false;
$precision = false;
$default = null;
if ($tableColumn['default'] !== null && $tableColumn['default'] !== 'NULL') { if ($tableColumn['default'] !== null && $tableColumn['default'] !== 'NULL') {
$default = $tableColumn['default']; $default = $tableColumn['default'];
...@@ -68,7 +65,6 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -68,7 +65,6 @@ class DB2SchemaManager extends AbstractSchemaManager
switch (strtolower($tableColumn['typename'])) { switch (strtolower($tableColumn['typename'])) {
case 'varchar': case 'varchar':
$length = $tableColumn['length']; $length = $tableColumn['length'];
$fixed = false;
break; break;
case 'character': case 'character':
$length = $tableColumn['length']; $length = $tableColumn['length'];
...@@ -88,12 +84,10 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -88,12 +84,10 @@ class DB2SchemaManager extends AbstractSchemaManager
$options = [ $options = [
'length' => $length, 'length' => $length,
'unsigned' => false, 'unsigned' => false,
'fixed' => (bool) $fixed, 'fixed' => $fixed,
'default' => $default, 'default' => $default,
'autoincrement' => (bool) $tableColumn['autoincrement'], 'autoincrement' => (bool) $tableColumn['autoincrement'],
'notnull' => (bool) ($tableColumn['nulls'] === 'N'), 'notnull' => $tableColumn['nulls'] === 'N',
'scale' => null,
'precision' => null,
'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== '' 'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== ''
? $tableColumn['comment'] ? $tableColumn['comment']
: null, : null,
......
...@@ -118,13 +118,13 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -118,13 +118,13 @@ class MySqlSchemaManager extends AbstractSchemaManager
$length = $tableColumn['length'] ?? strtok('(), '); $length = $tableColumn['length'] ?? strtok('(), ');
$fixed = null; $fixed = false;
if (! isset($tableColumn['name'])) { if (! isset($tableColumn['name'])) {
$tableColumn['name'] = ''; $tableColumn['name'] = '';
} }
$scale = null; $scale = 0;
$precision = null; $precision = null;
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment']) $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'])
...@@ -141,8 +141,8 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -141,8 +141,8 @@ class MySqlSchemaManager extends AbstractSchemaManager
case 'numeric': case 'numeric':
case 'decimal': case 'decimal':
if (preg_match('([A-Za-z]+\(([0-9]+)\,([0-9]+)\))', $tableColumn['type'], $match)) { if (preg_match('([A-Za-z]+\(([0-9]+)\,([0-9]+)\))', $tableColumn['type'], $match)) {
$precision = $match[1]; $precision = (int) $match[1];
$scale = $match[2]; $scale = (int) $match[2];
$length = null; $length = null;
} }
break; break;
...@@ -184,22 +184,17 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -184,22 +184,17 @@ class MySqlSchemaManager extends AbstractSchemaManager
$options = [ $options = [
'length' => $length !== null ? (int) $length : null, 'length' => $length !== null ? (int) $length : null,
'unsigned' => strpos($tableColumn['type'], 'unsigned') !== false, 'unsigned' => strpos($tableColumn['type'], 'unsigned') !== false,
'fixed' => (bool) $fixed, 'fixed' => $fixed,
'default' => $columnDefault, 'default' => $columnDefault,
'notnull' => $tableColumn['null'] !== 'YES', 'notnull' => $tableColumn['null'] !== 'YES',
'scale' => null, 'scale' => $scale,
'precision' => null, 'precision' => $precision,
'autoincrement' => strpos($tableColumn['extra'], 'auto_increment') !== false, 'autoincrement' => strpos($tableColumn['extra'], 'auto_increment') !== false,
'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== '' 'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== ''
? $tableColumn['comment'] ? $tableColumn['comment']
: null, : null,
]; ];
if ($scale !== null && $precision !== null) {
$options['scale'] = (int) $scale;
$options['precision'] = (int) $precision;
}
$column = new Column($tableColumn['field'], Type::getType($type), $options); $column = new Column($tableColumn['field'], Type::getType($type), $options);
if (isset($tableColumn['characterset'])) { if (isset($tableColumn['characterset'])) {
......
...@@ -133,7 +133,9 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -133,7 +133,9 @@ class OracleSchemaManager extends AbstractSchemaManager
} }
} }
$unsigned = $fixed = $precision = $scale = $length = null; $length = $precision = null;
$scale = 0;
$fixed = false;
if (! isset($tableColumn['column_name'])) { if (! isset($tableColumn['column_name'])) {
$tableColumn['column_name'] = ''; $tableColumn['column_name'] = '';
...@@ -182,20 +184,18 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -182,20 +184,18 @@ class OracleSchemaManager extends AbstractSchemaManager
case 'varchar': case 'varchar':
case 'varchar2': case 'varchar2':
case 'nvarchar2': case 'nvarchar2':
$length = $tableColumn['char_length']; $length = (int) $tableColumn['char_length'];
$fixed = false;
break; break;
case 'char': case 'char':
case 'nchar': case 'nchar':
$length = $tableColumn['char_length']; $length = (int) $tableColumn['char_length'];
$fixed = true; $fixed = true;
break; break;
} }
$options = [ $options = [
'notnull' => (bool) ($tableColumn['nullable'] === 'N'), 'notnull' => $tableColumn['nullable'] === 'N',
'fixed' => (bool) $fixed, 'fixed' => $fixed,
'unsigned' => (bool) $unsigned,
'default' => $tableColumn['data_default'], 'default' => $tableColumn['data_default'],
'length' => $length, 'length' => $length,
'precision' => $precision, 'precision' => $precision,
......
...@@ -20,7 +20,6 @@ use function explode; ...@@ -20,7 +20,6 @@ use function explode;
use function implode; use function implode;
use function in_array; use function in_array;
use function preg_match; use function preg_match;
use function preg_replace;
use function sprintf; use function sprintf;
use function str_replace; use function str_replace;
use function strlen; use function strlen;
...@@ -316,10 +315,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -316,10 +315,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
{ {
$tableColumn = array_change_key_case($tableColumn, CASE_LOWER); $tableColumn = array_change_key_case($tableColumn, CASE_LOWER);
if (strtolower($tableColumn['type']) === 'varchar' || strtolower($tableColumn['type']) === 'bpchar') { $length = null;
// get length from varchar definition
$length = preg_replace('~.*\(([0-9]*)\).*~', '$1', $tableColumn['complete_type']); if (in_array(strtolower($tableColumn['type']), ['varchar', 'bpchar'], true)
$tableColumn['length'] = $length; && preg_match('/\((\d*)\)/', $tableColumn['complete_type'], $matches)) {
$length = (int) $matches[1];
} }
$matches = []; $matches = [];
...@@ -339,21 +339,22 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -339,21 +339,22 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
} }
} }
$length = $tableColumn['length'] ?? null; if ($length === -1 && isset($tableColumn['atttypmod'])) {
if ($length === '-1' && isset($tableColumn['atttypmod'])) {
$length = $tableColumn['atttypmod'] - 4; $length = $tableColumn['atttypmod'] - 4;
} }
if ((int) $length <= 0) { if ((int) $length <= 0) {
$length = null; $length = null;
} }
$fixed = null;
$fixed = false;
if (! isset($tableColumn['name'])) { if (! isset($tableColumn['name'])) {
$tableColumn['name'] = ''; $tableColumn['name'] = '';
} }
$precision = null; $precision = null;
$scale = null; $scale = 0;
$jsonb = null; $jsonb = null;
$dbType = strtolower($tableColumn['type']); $dbType = strtolower($tableColumn['type']);
...@@ -401,10 +402,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -401,10 +402,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
case '_varchar': case '_varchar':
case 'varchar': case 'varchar':
$tableColumn['default'] = $this->parseDefaultExpression($tableColumn['default']); $tableColumn['default'] = $this->parseDefaultExpression($tableColumn['default']);
$fixed = false;
break;
case 'interval':
$fixed = false;
break; break;
case 'char': case 'char':
case 'bpchar': case 'bpchar':
...@@ -422,8 +419,8 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -422,8 +419,8 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']); $tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']);
if (preg_match('([A-Za-z]+\(([0-9]+)\,([0-9]+)\))', $tableColumn['complete_type'], $match)) { if (preg_match('([A-Za-z]+\(([0-9]+)\,([0-9]+)\))', $tableColumn['complete_type'], $match)) {
$precision = $match[1]; $precision = (int) $match[1];
$scale = $match[2]; $scale = (int) $match[2];
$length = null; $length = null;
} }
break; break;
......
...@@ -70,16 +70,27 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -70,16 +70,27 @@ class SQLServerSchemaManager extends AbstractSchemaManager
$dbType = strtok($tableColumn['type'], '(), '); $dbType = strtok($tableColumn['type'], '(), ');
assert(is_string($dbType)); assert(is_string($dbType));
$fixed = null; $length = (int) $tableColumn['length'];
$length = (int) $tableColumn['length'];
$default = $tableColumn['default']; $precision = $default = null;
$scale = 0;
$fixed = false;
if (! isset($tableColumn['name'])) { if (! isset($tableColumn['name'])) {
$tableColumn['name'] = ''; $tableColumn['name'] = '';
} }
if ($default !== null) { if ($tableColumn['scale'] !== null) {
$default = $this->parseDefaultExpression($default); $scale = (int) $tableColumn['scale'];
}
if ($tableColumn['precision'] !== null) {
$precision = (int) $tableColumn['precision'];
}
if ($tableColumn['default'] !== null) {
$default = $this->parseDefaultExpression($tableColumn['default']);
} }
switch ($dbType) { switch ($dbType) {
...@@ -106,12 +117,11 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -106,12 +117,11 @@ class SQLServerSchemaManager extends AbstractSchemaManager
$options = [ $options = [
'length' => $length === 0 || ! in_array($type, ['text', 'string']) ? null : $length, 'length' => $length === 0 || ! in_array($type, ['text', 'string']) ? null : $length,
'unsigned' => false, 'fixed' => $fixed,
'fixed' => (bool) $fixed,
'default' => $default, 'default' => $default,
'notnull' => (bool) $tableColumn['notnull'], 'notnull' => (bool) $tableColumn['notnull'],
'scale' => $tableColumn['scale'], 'scale' => $scale,
'precision' => $tableColumn['precision'], 'precision' => $precision,
'autoincrement' => (bool) $tableColumn['autoincrement'], 'autoincrement' => (bool) $tableColumn['autoincrement'],
'comment' => $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null, 'comment' => $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null,
]; ];
......
...@@ -12,10 +12,9 @@ use Doctrine\DBAL\Types\TextType; ...@@ -12,10 +12,9 @@ use Doctrine\DBAL\Types\TextType;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use const CASE_LOWER; use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
use function array_map;
use function array_reverse; use function array_reverse;
use function array_values; use function array_values;
use function explode; use function count;
use function file_exists; use function file_exists;
use function preg_match; use function preg_match;
use function preg_match_all; use function preg_match_all;
...@@ -300,23 +299,26 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -300,23 +299,26 @@ class SqliteSchemaManager extends AbstractSchemaManager
*/ */
protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableColumnDefinition($tableColumn)
{ {
$parts = explode('(', $tableColumn['type']); preg_match('/^([^()]*)\\s*(\\(((\\d+)(,\\s*(\\d+))?)\\))?/', $tableColumn['type'], $matches);
$tableColumn['type'] = trim($parts[0]);
if (isset($parts[1])) { $dbType = trim(strtolower($matches[1]));
$length = trim($parts[1], ')');
$tableColumn['length'] = $length;
}
$dbType = strtolower($tableColumn['type']); $length = $precision = $unsigned = null;
$length = $tableColumn['length'] ?? null; $fixed = $unsigned = false;
$unsigned = false; $scale = 0;
if (count($matches) >= 6) {
$precision = (int) $matches[4];
$scale = (int) $matches[6];
} elseif (count($matches) >= 4) {
$length = (int) $matches[4];
}
if (strpos($dbType, ' unsigned') !== false) { if (strpos($dbType, ' unsigned') !== false) {
$dbType = str_replace(' unsigned', '', $dbType); $dbType = str_replace(' unsigned', '', $dbType);
$unsigned = true; $unsigned = true;
} }
$fixed = false;
$type = $this->_platform->getDoctrineTypeMapping($dbType); $type = $this->_platform->getDoctrineTypeMapping($dbType);
$default = $tableColumn['dflt_value']; $default = $tableColumn['dflt_value'];
if ($default === 'NULL') { if ($default === 'NULL') {
...@@ -336,31 +338,13 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -336,31 +338,13 @@ class SqliteSchemaManager extends AbstractSchemaManager
$tableColumn['name'] = ''; $tableColumn['name'] = '';
} }
$precision = null; if ($dbType === 'char') {
$scale = null; $fixed = true;
switch ($dbType) {
case 'char':
$fixed = true;
break;
case 'float':
case 'double':
case 'real':
case 'decimal':
case 'numeric':
if (isset($tableColumn['length'])) {
if (strpos($tableColumn['length'], ',') === false) {
$tableColumn['length'] .= ',0';
}
[$precision, $scale] = array_map('trim', explode(',', $tableColumn['length']));
}
$length = null;
break;
} }
$options = [ $options = [
'length' => $length, 'length' => $length,
'unsigned' => (bool) $unsigned, 'unsigned' => $unsigned,
'fixed' => $fixed, 'fixed' => $fixed,
'notnull' => $notnull, 'notnull' => $notnull,
'default' => $default, 'default' => $default,
......
...@@ -164,10 +164,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -164,10 +164,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
$table = new Table('sqlsrv_column_comment'); $table = new Table('sqlsrv_column_comment');
$table->addColumn('id', 'integer', ['autoincrement' => true]); $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('comment_null', 'integer', ['comment' => null]); $table->addColumn('comment_null', 'integer', ['comment' => null]);
$table->addColumn('comment_false', 'integer', ['comment' => false]);
$table->addColumn('comment_empty_string', 'integer', ['comment' => '']); $table->addColumn('comment_empty_string', 'integer', ['comment' => '']);
$table->addColumn('comment_integer_0', 'integer', ['comment' => 0]);
$table->addColumn('comment_float_0', 'integer', ['comment' => 0.0]);
$table->addColumn('comment_string_0', 'integer', ['comment' => '0']); $table->addColumn('comment_string_0', 'integer', ['comment' => '0']);
$table->addColumn('comment', 'integer', ['comment' => 'Doctrine 0wnz you!']); $table->addColumn('comment', 'integer', ['comment' => 'Doctrine 0wnz you!']);
$table->addColumn('`comment_quoted`', 'integer', ['comment' => 'Doctrine 0wnz comments for explicitly quoted columns!']); $table->addColumn('`comment_quoted`', 'integer', ['comment' => 'Doctrine 0wnz comments for explicitly quoted columns!']);
...@@ -179,13 +176,10 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -179,13 +176,10 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->schemaManager->createTable($table); $this->schemaManager->createTable($table);
$columns = $this->schemaManager->listTableColumns('sqlsrv_column_comment'); $columns = $this->schemaManager->listTableColumns('sqlsrv_column_comment');
self::assertCount(12, $columns); self::assertCount(9, $columns);
self::assertNull($columns['id']->getComment()); self::assertNull($columns['id']->getComment());
self::assertNull($columns['comment_null']->getComment()); self::assertNull($columns['comment_null']->getComment());
self::assertNull($columns['comment_false']->getComment());
self::assertNull($columns['comment_empty_string']->getComment()); self::assertNull($columns['comment_empty_string']->getComment());
self::assertEquals('0', $columns['comment_integer_0']->getComment());
self::assertEquals('0', $columns['comment_float_0']->getComment());
self::assertEquals('0', $columns['comment_string_0']->getComment()); self::assertEquals('0', $columns['comment_string_0']->getComment());
self::assertEquals('Doctrine 0wnz you!', $columns['comment']->getComment()); self::assertEquals('Doctrine 0wnz you!', $columns['comment']->getComment());
self::assertEquals('Doctrine 0wnz comments for explicitly quoted columns!', $columns['comment_quoted']->getComment()); self::assertEquals('Doctrine 0wnz comments for explicitly quoted columns!', $columns['comment_quoted']->getComment());
...@@ -197,10 +191,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -197,10 +191,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
$tableDiff->fromTable = $table; $tableDiff->fromTable = $table;
$tableDiff->addedColumns['added_comment_none'] = new Column('added_comment_none', Type::getType('integer')); $tableDiff->addedColumns['added_comment_none'] = new Column('added_comment_none', Type::getType('integer'));
$tableDiff->addedColumns['added_comment_null'] = new Column('added_comment_null', Type::getType('integer'), ['comment' => null]); $tableDiff->addedColumns['added_comment_null'] = new Column('added_comment_null', Type::getType('integer'), ['comment' => null]);
$tableDiff->addedColumns['added_comment_false'] = new Column('added_comment_false', Type::getType('integer'), ['comment' => false]);
$tableDiff->addedColumns['added_comment_empty_string'] = new Column('added_comment_empty_string', Type::getType('integer'), ['comment' => '']); $tableDiff->addedColumns['added_comment_empty_string'] = new Column('added_comment_empty_string', Type::getType('integer'), ['comment' => '']);
$tableDiff->addedColumns['added_comment_integer_0'] = new Column('added_comment_integer_0', Type::getType('integer'), ['comment' => 0]);
$tableDiff->addedColumns['added_comment_float_0'] = new Column('added_comment_float_0', Type::getType('integer'), ['comment' => 0.0]);
$tableDiff->addedColumns['added_comment_string_0'] = new Column('added_comment_string_0', Type::getType('integer'), ['comment' => '0']); $tableDiff->addedColumns['added_comment_string_0'] = new Column('added_comment_string_0', Type::getType('integer'), ['comment' => '0']);
$tableDiff->addedColumns['added_comment'] = new Column('added_comment', Type::getType('integer'), ['comment' => 'Doctrine']); $tableDiff->addedColumns['added_comment'] = new Column('added_comment', Type::getType('integer'), ['comment' => 'Doctrine']);
$tableDiff->addedColumns['`added_comment_quoted`'] = new Column('`added_comment_quoted`', Type::getType('integer'), ['comment' => 'rulez']); $tableDiff->addedColumns['`added_comment_quoted`'] = new Column('`added_comment_quoted`', Type::getType('integer'), ['comment' => 'rulez']);
...@@ -208,8 +199,6 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -208,8 +199,6 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
$tableDiff->addedColumns['added_commented_type'] = new Column('added_commented_type', Type::getType('object')); $tableDiff->addedColumns['added_commented_type'] = new Column('added_commented_type', Type::getType('object'));
$tableDiff->addedColumns['added_commented_type_with_comment'] = new Column('added_commented_type_with_comment', Type::getType('array'), ['comment' => '666']); $tableDiff->addedColumns['added_commented_type_with_comment'] = new Column('added_commented_type_with_comment', Type::getType('array'), ['comment' => '666']);
$tableDiff->renamedColumns['comment_float_0'] = new Column('comment_double_0', Type::getType('decimal'), ['comment' => 'Double for real!']);
// Add comment to non-commented column. // Add comment to non-commented column.
$tableDiff->changedColumns['id'] = new ColumnDiff( $tableDiff->changedColumns['id'] = new ColumnDiff(
'id', 'id',
...@@ -226,14 +215,6 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -226,14 +215,6 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
new Column('comment_null', Type::getType('integer'), ['comment' => null]) new Column('comment_null', Type::getType('integer'), ['comment' => null])
); );
// Add comment to false-commented column.
$tableDiff->changedColumns['comment_false'] = new ColumnDiff(
'comment_false',
new Column('comment_false', Type::getType('integer'), ['comment' => 'false']),
['comment'],
new Column('comment_false', Type::getType('integer'), ['comment' => false])
);
// Change type to custom type from empty string commented column. // Change type to custom type from empty string commented column.
$tableDiff->changedColumns['comment_empty_string'] = new ColumnDiff( $tableDiff->changedColumns['comment_empty_string'] = new ColumnDiff(
'comment_empty_string', 'comment_empty_string',
...@@ -242,10 +223,10 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -242,10 +223,10 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
new Column('comment_empty_string', Type::getType('integer'), ['comment' => '']) new Column('comment_empty_string', Type::getType('integer'), ['comment' => ''])
); );
// Change comment to false-comment from zero-string commented column. // Change comment to empty comment from zero-string commented column.
$tableDiff->changedColumns['comment_string_0'] = new ColumnDiff( $tableDiff->changedColumns['comment_string_0'] = new ColumnDiff(
'comment_string_0', 'comment_string_0',
new Column('comment_string_0', Type::getType('integer'), ['comment' => false]), new Column('comment_string_0', Type::getType('integer'), ['comment' => '']),
['comment'], ['comment'],
new Column('comment_string_0', Type::getType('integer'), ['comment' => '0']) new Column('comment_string_0', Type::getType('integer'), ['comment' => '0'])
); );
...@@ -290,17 +271,13 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -290,17 +271,13 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
new Column('commented_type_with_comment', Type::getType('array'), ['comment' => 'Doctrine array type.']) new Column('commented_type_with_comment', Type::getType('array'), ['comment' => 'Doctrine array type.'])
); );
$tableDiff->removedColumns['comment_integer_0'] = new Column('comment_integer_0', Type::getType('integer'), ['comment' => 0]);
$this->schemaManager->alterTable($tableDiff); $this->schemaManager->alterTable($tableDiff);
$columns = $this->schemaManager->listTableColumns('sqlsrv_column_comment'); $columns = $this->schemaManager->listTableColumns('sqlsrv_column_comment');
self::assertCount(23, $columns); self::assertCount(18, $columns);
self::assertEquals('primary', $columns['id']->getComment()); self::assertEquals('primary', $columns['id']->getComment());
self::assertNull($columns['comment_null']->getComment()); self::assertNull($columns['comment_null']->getComment());
self::assertEquals('false', $columns['comment_false']->getComment());
self::assertNull($columns['comment_empty_string']->getComment()); self::assertNull($columns['comment_empty_string']->getComment());
self::assertEquals('0', $columns['comment_double_0']->getComment());
self::assertNull($columns['comment_string_0']->getComment()); self::assertNull($columns['comment_string_0']->getComment());
self::assertNull($columns['comment']->getComment()); self::assertNull($columns['comment']->getComment());
self::assertEquals('Doctrine array.', $columns['comment_quoted']->getComment()); self::assertEquals('Doctrine array.', $columns['comment_quoted']->getComment());
...@@ -309,10 +286,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -309,10 +286,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertNull($columns['commented_type_with_comment']->getComment()); self::assertNull($columns['commented_type_with_comment']->getComment());
self::assertNull($columns['added_comment_none']->getComment()); self::assertNull($columns['added_comment_none']->getComment());
self::assertNull($columns['added_comment_null']->getComment()); self::assertNull($columns['added_comment_null']->getComment());
self::assertNull($columns['added_comment_false']->getComment());
self::assertNull($columns['added_comment_empty_string']->getComment()); self::assertNull($columns['added_comment_empty_string']->getComment());
self::assertEquals('0', $columns['added_comment_integer_0']->getComment());
self::assertEquals('0', $columns['added_comment_float_0']->getComment());
self::assertEquals('0', $columns['added_comment_string_0']->getComment()); self::assertEquals('0', $columns['added_comment_string_0']->getComment());
self::assertEquals('Doctrine', $columns['added_comment']->getComment()); self::assertEquals('Doctrine', $columns['added_comment']->getComment());
self::assertEquals('rulez', $columns['added_comment_quoted']->getComment()); self::assertEquals('rulez', $columns['added_comment_quoted']->getComment());
......
...@@ -1224,7 +1224,7 @@ class ComparatorTest extends TestCase ...@@ -1224,7 +1224,7 @@ class ComparatorTest extends TestCase
$column2 = new Column( $column2 = new Column(
'foo', 'foo',
Type::getType('guid'), Type::getType('guid'),
['notnull' => false, 'length' => '36', 'fixed' => true, 'default' => 'NEWID()', 'comment' => 'GUID 2.'] ['notnull' => false, 'length' => 36, 'fixed' => true, 'default' => 'NEWID()', 'comment' => 'GUID 2.']
); );
self::assertEquals(['notnull', 'default', 'comment'], $comparator->diffColumn($column1, $column2)); self::assertEquals(['notnull', 'default', 'comment'], $comparator->diffColumn($column1, $column2));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment