diff --git a/lib/Doctrine/DBAL/Schema/Comparator.php b/lib/Doctrine/DBAL/Schema/Comparator.php index e2114e84c13..a2108fb4ecf 100644 --- a/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/lib/Doctrine/DBAL/Schema/Comparator.php @@ -435,6 +435,13 @@ public function diffColumn(Column $column1, Column $column2) } } + // This is a very nasty hack to make comparator work with the legacy json_array type, which should be killed in v3 + if ($this->isALegacyJsonComparison($properties1['type'], $properties2['type'])) { + array_shift($changedProperties); + + $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. @@ -497,6 +504,21 @@ public function diffColumn(Column $column1, Column $column2) return array_unique($changedProperties); } + /** + * TODO: kill with fire on v3.0 + * + * @deprecated + */ + private function isALegacyJsonComparison(Types\Type $one, Types\Type $other) : bool + { + if ( ! $one instanceof Types\JsonType || ! $other instanceof Types\JsonType) { + return false; + } + + return ( ! $one instanceof Types\JsonArrayType && $other instanceof Types\JsonArrayType) + || ( ! $other instanceof Types\JsonArrayType && $one instanceof Types\JsonArrayType); + } + /** * Finds the difference between the indexes $index1 and $index2. *