Orm: DBAL SchemaManager ignores float `precision` and `scale`

Created on 29 Jul 2016  路  4Comments  路  Source: doctrine/orm

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.

Most helpful comment

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,
)

All 4 comments

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,
)

Same issue here

Same here

+1

Was this page helpful?
0 / 5 - 0 ratings