diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index 11b397a74a..39d6417507 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -1400,7 +1400,7 @@ public function normalizeTable(Table $table) foreach ($table->getColumns() as $column) { if ($column->getSize() && $defaultSize = $this->getDefaultTypeSize($column->getType())) { - if (intval($column->getSize()) === $defaultSize) { + if (null === $column->getScale() && intval($column->getSize()) === $defaultSize) { $column->setSize(null); } } diff --git a/src/Propel/Generator/Reverse/MysqlSchemaParser.php b/src/Propel/Generator/Reverse/MysqlSchemaParser.php index 95471e10f9..1c1b3cd712 100644 --- a/src/Propel/Generator/Reverse/MysqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MysqlSchemaParser.php @@ -207,7 +207,7 @@ public function getColumnFromRow($row, Table $table) if ($matches[3]) { $sqlType = $row['Type']; } - if (isset(static::$defaultTypeSizes[$nativeType]) && $size === static::$defaultTypeSizes[$nativeType]) { + if (isset(static::$defaultTypeSizes[$nativeType]) && null == $scale && $size === static::$defaultTypeSizes[$nativeType]) { $size = null; } } elseif (preg_match('/^(\w+)\(/', $row['Type'], $matches)) { diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php index b68463fc4f..b24ce4d96f 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php @@ -839,4 +839,19 @@ public function testVendorOptionsQuoting() $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + + public function testNormalizeTable() + { + $column = new Column('price', 'DECIMAL'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DECIMAL')); + $column->setSize(10); + $column->setScale(3); + $table = new Table('prices'); + $table->addColumns([$column]); + $this->getPlatform()->normalizeTable($table); + $this->assertEquals("`price` DECIMAL(10,3)", $this->getPlatform()->getColumnDDL($column)); + } + + + }