diff --git a/src/Schema/Column.php b/src/Schema/Column.php index 69035f7bad..9e2e118d13 100644 --- a/src/Schema/Column.php +++ b/src/Schema/Column.php @@ -9,10 +9,12 @@ use Doctrine\DBAL\Schema\Name\Parser\UnqualifiedNameParser; use Doctrine\DBAL\Schema\Name\Parsers; use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Types\FloatType; use Doctrine\DBAL\Types\Type; use Doctrine\Deprecations\Deprecation; use function array_merge; +use function is_numeric; use function method_exists; /** @@ -384,10 +386,16 @@ public function getValues(): array /** @return ColumnProperties */ public function toArray(): array { + if ($this->_type instanceof FloatType && is_numeric($this->_default)) { + $default = (float) $this->_default; + } else { + $default = $this->_default; + } + return array_merge([ 'name' => $this->_name, 'type' => $this->_type, - 'default' => $this->_default, + 'default' => $default, 'notnull' => $this->_notnull, 'length' => $this->_length, 'precision' => $this->_precision, diff --git a/tests/Functional/Schema/ComparatorTest.php b/tests/Functional/Schema/ComparatorTest.php index f08b304360..775abaedbf 100644 --- a/tests/Functional/Schema/ComparatorTest.php +++ b/tests/Functional/Schema/ComparatorTest.php @@ -147,6 +147,7 @@ public static function defaultValueProvider(): iterable { return [ [Types::INTEGER, 1], + [Types::FLOAT, 42.0], [Types::BOOLEAN, false], [Types::TEXT, 'Doctrine'], ];