Commit fa75b7bf authored by Steve Müller's avatar Steve Müller

mark commented types implicitly

parent 475097dd
......@@ -400,6 +400,12 @@ abstract class AbstractPlatform
$dbType = strtolower($dbType);
$this->doctrineTypeMapping[$dbType] = $doctrineType;
$doctrineType = Type::getType($doctrineType);
if ($doctrineType->requiresSQLCommentHint($this)) {
$this->markDoctrineTypeCommented($doctrineType);
}
}
/**
......
......@@ -13,6 +13,7 @@ use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\Types\CommentedType;
abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{
......@@ -107,6 +108,21 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$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
*
......
<?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