Commit 0b609e49 authored by Steve Müller's avatar Steve Müller

optimize non-native GUID type declaration

parent 6ccd739c
......@@ -297,7 +297,7 @@ abstract class AbstractPlatform
/**
* Returns the SQL snippet to declare a GUID/UUID field.
*
* By default this maps directly to a VARCHAR and only maps to more
* By default this maps directly to a CHAR(36) and only maps to more
* special datatypes when the underlying databases support this datatype.
*
* @param array $field
......@@ -306,6 +306,9 @@ abstract class AbstractPlatform
*/
public function getGuidTypeDeclarationSQL(array $field)
{
$field['length'] = 36;
$field['fixed'] = true;
return $this->getVarcharTypeDeclarationSQL($field);
}
......
......@@ -596,4 +596,12 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
"CHANGE `select` `select` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 3'"
);
}
/**
* @group DBAL-423
*/
public function testReturnsGuidTypeDeclarationSQL()
{
$this->assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(array()));
}
}
......@@ -946,4 +946,14 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->_platform->quoteStringLiteral($c)
);
}
/**
* @group DBAL-423
*
* @expectedException \Doctrine\DBAL\DBALException
*/
public function testReturnsGuidTypeDeclarationSQL()
{
$this->_platform->getGuidTypeDeclarationSQL(array());
}
}
......@@ -664,4 +664,12 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
$this->_platform->getCommentOnColumnSQL('mytable', 'id', null)
);
}
/**
* @group DBAL-423
*/
public function testReturnsGuidTypeDeclarationSQL()
{
$this->assertSame('UUID', $this->_platform->getGuidTypeDeclarationSQL(array()));
}
}
......@@ -1101,4 +1101,12 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
),
);
}
/**
* @group DBAL-423
*/
public function testReturnsGuidTypeDeclarationSQL()
{
$this->assertSame('UNIQUEIDENTIFIER', $this->_platform->getGuidTypeDeclarationSQL(array()));
}
}
......@@ -463,4 +463,12 @@ class DB2PlatformTest extends AbstractPlatformTestCase
'RENAME INDEX "schema"."foo" TO "bar"',
);
}
/**
* @group DBAL-423
*/
public function testReturnsGuidTypeDeclarationSQL()
{
$this->assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(array()));
}
}
......@@ -484,4 +484,12 @@ class OraclePlatformTest extends AbstractPlatformTestCase
'ALTER INDEX "schema"."foo" RENAME TO "bar"',
);
}
/**
* @group DBAL-423
*/
public function testReturnsGuidTypeDeclarationSQL()
{
$this->assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(array()));
}
}
......@@ -855,4 +855,12 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
'ALTER INDEX "foo" ON "schema"."table" RENAME TO "bar"',
);
}
/**
* @group DBAL-423
*/
public function testReturnsGuidTypeDeclarationSQL()
{
$this->assertSame('UNIQUEIDENTIFIER', $this->_platform->getGuidTypeDeclarationSQL(array()));
}
}
......@@ -552,4 +552,12 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
'when used with schemas.'
);
}
/**
* @group DBAL-423
*/
public function testReturnsGuidTypeDeclarationSQL()
{
$this->assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(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