diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 75c3e593f..41b4f8795 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -236,6 +236,12 @@ class SchemaTool $column['type'] = Type::getType($mapping['type']); $column['length'] = isset($mapping['length']) ? $mapping['length'] : null; $column['notnull'] = isset($mapping['nullable']) ? ! $mapping['nullable'] : false; + if (isset($mapping['precision'])) { + $column['precision'] = $mapping['precision']; + } + if (isset($mapping['scale'])) { + $column['scale'] = $mapping['scale']; + } if (isset($mapping['default'])) { $column['default'] = $mapping['default']; } diff --git a/tests/Doctrine/Tests/Models/Generic/DecimalModel.php b/tests/Doctrine/Tests/Models/Generic/DecimalModel.php new file mode 100644 index 000000000..3ea1d03ce --- /dev/null +++ b/tests/Doctrine/Tests/Models/Generic/DecimalModel.php @@ -0,0 +1,20 @@ +addTestSuite('Doctrine\Tests\ORM\Functional\SchemaTool\MySqlSchemaToolTest'); + //$suite->addTestSuite('Doctrine\Tests\ORM\Functional\SchemaTool\PostgreSqlSchemaToolTest'); return $suite; } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 7e57c8e98..86e160d00 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -37,6 +37,19 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertEquals("ALTER TABLE cms_phonenumbers ADD FOREIGN KEY (user_id) REFERENCES cms_users(id)", $sql[7]); } + public function testGetCreateSchemaSql2() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\DecimalModel') + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + $this->assertEquals(1, count($sql)); + $this->assertEquals("CREATE TABLE date_time_model (id INT AUTO_INCREMENT NOT NULL, decimal NUMERIC(2, 5) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]); + } + public function testGetUpdateSchemaSql() { $classes = array(