Commit 9af1743a authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub

Merge pull request #2603 from deeky666/DBAL-2594

[DBAL-2594] Mark commented types implicitly
parents 475097dd fa75b7bf
...@@ -400,6 +400,12 @@ abstract class AbstractPlatform ...@@ -400,6 +400,12 @@ abstract class AbstractPlatform
$dbType = strtolower($dbType); $dbType = strtolower($dbType);
$this->doctrineTypeMapping[$dbType] = $doctrineType; $this->doctrineTypeMapping[$dbType] = $doctrineType;
$doctrineType = Type::getType($doctrineType);
if ($doctrineType->requiresSQLCommentHint($this)) {
$this->markDoctrineTypeCommented($doctrineType);
}
} }
/** /**
......
...@@ -13,6 +13,7 @@ use Doctrine\DBAL\Schema\Index; ...@@ -13,6 +13,7 @@ use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\Types\CommentedType;
abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{ {
...@@ -107,6 +108,21 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -107,6 +108,21 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->_platform->registerDoctrineTypeMapping('foo', 'bar'); $this->_platform->registerDoctrineTypeMapping('foo', 'bar');
} }
/**
* @group DBAL-2594
*/
public function testRegistersCommentedDoctrineMappingTypeImplicitly()
{
if (!Type::hasType('my_commented')) {
Type::addType('my_commented', CommentedType::class);
}
$type = Type::getType('my_commented');
$this->_platform->registerDoctrineTypeMapping('foo', 'my_commented');
$this->assertTrue($this->_platform->isCommentedDoctrineType($type));
}
/** /**
* @group DBAL-939 * @group DBAL-939
* *
......
<?php
namespace Doctrine\Tests\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
class CommentedType extends Type
{
public function getName()
{
return 'my_commented';
}
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return strtoupper($this->getName());
}
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
}
}
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