DBAL SchemaManager ignores float precision and scale #5204

Open
opened 2026-01-22 15:01:32 +01:00 by admin · 4 comments
Owner

Originally created by @neomerx on GitHub (Jul 29, 2016).

When a new column is added for float type with scale and precision they are ignored.

$table->addColumn($name, Type::FLOAT)->setPrecision($precision)->setScale($scale);

will produce DOUBLE (in MySQL) no matter what is given in $precision and $scale.

The only usage of getPrecision and getScale is here.

Originally created by @neomerx on GitHub (Jul 29, 2016). When a new column is added for `float` type with `scale` and `precision` they are ignored. ``` php $table->addColumn($name, Type::FLOAT)->setPrecision($precision)->setScale($scale); ``` will produce `DOUBLE` (in MySQL) no matter what is given in `$precision` and `$scale`. The only usage of `getPrecision` and `getScale` is [here](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php#L415-L416).
Author
Owner

@neomerx commented on GitHub (Jul 29, 2016):

I think the problem is with method AbstractPlatform::getFloatDeclarationSQL

    public function getFloatDeclarationSQL(array $fieldDeclaration)
    {
        return 'DOUBLE PRECISION';
    }

it receives valid precision and scale but just ignores the values

array (
  'name' => 'latitude',
  'type' => 
  Doctrine\DBAL\Types\FloatType::__set_state(array(
  )),
  'default' => NULL,
  'notnull' => true,
  'length' => NULL,
  'precision' => 17,
  'scale' => 14,
  'fixed' => false,
  'unsigned' => false,
  'autoincrement' => false,
  'columnDefinition' => NULL,
  'comment' => NULL,
  'version' => false,
)
@neomerx commented on GitHub (Jul 29, 2016): I think the problem is with [method AbstractPlatform::getFloatDeclarationSQL](https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php#L2981-L2984) ``` php public function getFloatDeclarationSQL(array $fieldDeclaration) { return 'DOUBLE PRECISION'; } ``` it receives valid `precision` and `scale` but just ignores the values ``` php array ( 'name' => 'latitude', 'type' => Doctrine\DBAL\Types\FloatType::__set_state(array( )), 'default' => NULL, 'notnull' => true, 'length' => NULL, 'precision' => 17, 'scale' => 14, 'fixed' => false, 'unsigned' => false, 'autoincrement' => false, 'columnDefinition' => NULL, 'comment' => NULL, 'version' => false, ) ```
Author
Owner

@keanolane commented on GitHub (Aug 8, 2016):

Same issue here

@keanolane commented on GitHub (Aug 8, 2016): Same issue here
Author
Owner

@sergiodebcn commented on GitHub (May 31, 2018):

Same here

@sergiodebcn commented on GitHub (May 31, 2018): Same here
Author
Owner

@marc-tomas-atrapalo commented on GitHub (Jun 4, 2018):

+1

@marc-tomas-atrapalo commented on GitHub (Jun 4, 2018): +1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5204