From 3ef0bf50e992b647a27a766fd6e85801721d4fb0 Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Sat, 5 Sep 2009 02:44:45 +0000 Subject: [PATCH] [2.0] Other fixes, removed E_FATAL of duplicate declaration and added test for Boolean type --- lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php | 12 +++--------- lib/Doctrine/DBAL/Platforms/OraclePlatform.php | 8 -------- .../DBAL/Platforms/PostgreSqlPlatform.php | 8 -------- tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php | 1 + .../Doctrine/Tests/Mocks/DatabasePlatformMock.php | 3 +++ .../Tests/Models/Generic/DecimalModel.php | 2 +- .../Functional/SchemaTool/MySqlSchemaToolTest.php | 15 ++++++++++++++- 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php index c323fbf15..dcf23bf1e 100644 --- a/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php @@ -325,14 +325,6 @@ class MsSqlPlatform extends AbstractPlatform return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSql($level); } - /** - * @override - */ - public function getBooleanTypeDeclarationSql(array $field) - { - return 'BIT'; - } - /** * @override */ @@ -374,7 +366,9 @@ class MsSqlPlatform extends AbstractPlatform : ($length ? 'VARCHAR(' . $length . ')' : 'TEXT'); } - /** @override */ + /** + * @override + */ protected function _getCommonIntegerTypeDeclarationSql(array $columnDef) { $autoinc = ''; diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index 090b8e69b..2163f6db5 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -193,14 +193,6 @@ class OraclePlatform extends AbstractPlatform return 'TIMESTAMP(0) WITH TIME ZONE'; } - /** - * @override - */ - public function getBooleanTypeDeclarationSql(array $field) - { - return 'NUMBER(1)'; - } - /** * @override */ diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index 48aff9dcb..5becb6934 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -712,14 +712,6 @@ class PostgreSqlPlatform extends AbstractPlatform return 'DATE'; } - /** - * @override - */ - public function getBooleanTypeDeclarationSql(array $field) - { - return 'BOOLEAN'; - } - /** * @override */ diff --git a/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php b/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php index c354f8fc2..43eb93533 100644 --- a/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php +++ b/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Platforms; class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform { + public function getBooleanTypeDeclarationSql(array $columnDef) {} public function getIntegerTypeDeclarationSql(array $columnDef) {} public function getBigIntTypeDeclarationSql(array $columnDef) {} public function getSmallIntTypeDeclarationSql(array $columnDef) {} diff --git a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php b/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php index a588139b7..8fdfe871b 100644 --- a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php +++ b/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php @@ -40,6 +40,9 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform return $this->_sequenceNextValSql; } + /** @override */ + public function getBooleanTypeDeclarationSql(array $field) {} + /** @override */ public function getIntegerTypeDeclarationSql(array $field) {} diff --git a/tests/Doctrine/Tests/Models/Generic/DecimalModel.php b/tests/Doctrine/Tests/Models/Generic/DecimalModel.php index 3ea1d03ce..a401c1975 100644 --- a/tests/Doctrine/Tests/Models/Generic/DecimalModel.php +++ b/tests/Doctrine/Tests/Models/Generic/DecimalModel.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\Models\Generic; /** * @Entity - * @Table(name="date_time_model") + * @Table(name="decimal_model") */ class DecimalModel { diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 86e160d00..db9bf376c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -47,7 +47,20 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase $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]); + $this->assertEquals("CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, decimal NUMERIC(2, 5) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]); + } + + public function testGetCreateSchemaSql3() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\BooleanModel') + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + $this->assertEquals(1, count($sql)); + $this->assertEquals("CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, boolean DEFAULT 1 NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]); } public function testGetUpdateSchemaSql()