[2.0] Fixed scale/precision support in SchemaTool
This commit is contained in:
parent
60b31c7ae0
commit
a65ea05f01
@ -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'];
|
||||
}
|
||||
|
20
tests/Doctrine/Tests/Models/Generic/DecimalModel.php
Normal file
20
tests/Doctrine/Tests/Models/Generic/DecimalModel.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\Generic;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="date_time_model")
|
||||
*/
|
||||
class DecimalModel
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* @Column(type="decimal", scale=5, precision=2)
|
||||
*/
|
||||
public $decimal;
|
||||
}
|
@ -20,6 +20,7 @@ class AllTests
|
||||
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Orm Functional Tools');
|
||||
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\SchemaTool\MySqlSchemaToolTest');
|
||||
//$suite->addTestSuite('Doctrine\Tests\ORM\Functional\SchemaTool\PostgreSqlSchemaToolTest');
|
||||
|
||||
return $suite;
|
||||
}
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user