Commit a65ea05f authored by romanb's avatar romanb

[2.0] Fixed scale/precision support in SchemaTool

parent 60b31c7a
......@@ -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'];
}
......
<?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;
}
\ No newline at end of file
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment