diff --git a/lib/Doctrine/DBAL/Schema/Comparator.php b/lib/Doctrine/DBAL/Schema/Comparator.php index f95417face2..3b5a0b155d0 100644 --- a/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/lib/Doctrine/DBAL/Schema/Comparator.php @@ -432,12 +432,10 @@ public function diffColumn(Column $column1, Column $column2) $changedProperties[] = 'comment'; } - if ($properties1['default'] !== $properties2['default'] || - // Null values need to be checked additionally as they tell whether to create or drop a default value. - // null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation. - ($properties1['default'] === null && $properties2['default'] !== null) || - ($properties2['default'] === null && $properties1['default'] !== null) - ) { + // Null values need to be checked additionally as they tell whether to create or drop a default value. + // null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation. + if (($properties1['default'] === null) !== ($properties2['default'] === null) + || (string) $properties1['default'] !== (string) $properties2['default']) { $changedProperties[] = 'default'; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php new file mode 100644 index 00000000000..a97eb90bbce --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php @@ -0,0 +1,39 @@ +schemaManager = $this->connection->getSchemaManager(); + $this->comparator = new Comparator(); + } + + public function testDefaultValueComparison() + { + $table = new Table('default_value'); + $table->addColumn('id', 'integer', ['default' => 1]); + + $this->schemaManager->createTable($table); + + $onlineTable = $this->schemaManager->listTableDetails('default_value'); + + self::assertFalse($this->comparator->diffTable($table, $onlineTable)); + } +} diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php index b1669e345f5..475dcee3ee6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php @@ -23,6 +23,8 @@ protected function setUp() return; } + $this->resetSharedConn(); + Type::addType('point', MySqlPointType::class); }