From a18655055068348fa68801b59123070a4ca98973 Mon Sep 17 00:00:00 2001 From: Tomas Jacik Date: Sun, 13 Mar 2016 21:31:55 +0100 Subject: [PATCH] Drop ENUM type --- src/Kdyby/Doctrine/Connection.php | 11 ++++---- src/Kdyby/Doctrine/DI/OrmExtension.php | 4 +-- src/Kdyby/Doctrine/DbalType.php | 27 ------------------- src/Kdyby/Doctrine/Helpers.php | 3 ++- tests/KdybyTests/Doctrine/Connection.phpt | 6 ++--- .../KdybyTests/DoctrineMocks/TestTypeMock.php | 7 +++-- 6 files changed, 14 insertions(+), 44 deletions(-) delete mode 100644 src/Kdyby/Doctrine/DbalType.php rename src/Kdyby/Doctrine/Types/Enum.php => tests/KdybyTests/DoctrineMocks/TestTypeMock.php (87%) diff --git a/src/Kdyby/Doctrine/Connection.php b/src/Kdyby/Doctrine/Connection.php index b50cef42..b2a0fe76 100644 --- a/src/Kdyby/Doctrine/Connection.php +++ b/src/Kdyby/Doctrine/Connection.php @@ -12,6 +12,7 @@ use Doctrine; use Doctrine\Common\EventManager; +use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Driver; use Kdyby; use Nette; @@ -279,11 +280,11 @@ public function connect() } foreach ($this->dbalTypes as $name => $className) { - if (DbalType::hasType($name)) { - DbalType::overrideType($name, $className); + if (Type::hasType($name)) { + Type::overrideType($name, $className); } else { - DbalType::addType($name, $className); + Type::addType($name, $className); } } @@ -296,7 +297,7 @@ public function connect() } foreach ($this->dbalTypes as $type => $className) { - $platform->markDoctrineTypeCommented(DbalType::getType($type)); + $platform->markDoctrineTypeCommented(Type::getType($type)); } return TRUE; @@ -351,8 +352,6 @@ public function ping() * @param array $params * @param \Doctrine\DBAL\Configuration $config * @param \Doctrine\Common\EventManager $eventManager - * @param array $dbalTypes - * @param array $schemaTypes * @return Connection */ public static function create(array $params, Doctrine\DBAL\Configuration $config, EventManager $eventManager) diff --git a/src/Kdyby/Doctrine/DI/OrmExtension.php b/src/Kdyby/Doctrine/DI/OrmExtension.php index 8cf0d6b5..9b1d5398 100644 --- a/src/Kdyby/Doctrine/DI/OrmExtension.php +++ b/src/Kdyby/Doctrine/DI/OrmExtension.php @@ -93,9 +93,7 @@ class OrmExtension extends Nette\DI\CompilerExtension 'platformService' => NULL, 'defaultTableOptions' => [], 'resultCache' => 'default', - 'types' => [ - 'enum' => 'Kdyby\Doctrine\Types\Enum', - ], + 'types' => [], 'schemaFilter' => NULL, ]; diff --git a/src/Kdyby/Doctrine/DbalType.php b/src/Kdyby/Doctrine/DbalType.php deleted file mode 100644 index 6ad81cbb..00000000 --- a/src/Kdyby/Doctrine/DbalType.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -abstract class DbalType extends Doctrine\DBAL\Types\Type -{ - - const ENUM = 'enum'; - -} diff --git a/src/Kdyby/Doctrine/Helpers.php b/src/Kdyby/Doctrine/Helpers.php index a728d711..d2887f57 100644 --- a/src/Kdyby/Doctrine/Helpers.php +++ b/src/Kdyby/Doctrine/Helpers.php @@ -12,6 +12,7 @@ use Kdyby; use Nette; +use Doctrine\DBAL\Types\Type; @@ -44,7 +45,7 @@ public static function separateParameters($query, array $args) $type = NULL; if ($value instanceof \DateTime || $value instanceof \DateTimeImmutable) { - $type = DbalType::DATETIME; + $type = Type::DATETIME; } elseif (is_array($value)) { $type = Connection::PARAM_STR_ARRAY; diff --git a/tests/KdybyTests/Doctrine/Connection.phpt b/tests/KdybyTests/Doctrine/Connection.phpt index 44a193da..996fd667 100644 --- a/tests/KdybyTests/Doctrine/Connection.phpt +++ b/tests/KdybyTests/Doctrine/Connection.phpt @@ -120,13 +120,13 @@ class ConnectionTest extends Tester\TestCase 'memory' => TRUE, ], new Doctrine\DBAL\Driver\PDOSqlite\Driver()); $conn->setSchemaTypes([ - 'enum' => 'enum', + 'test' => 'test', ]); $conn->setDbalTypes([ - 'enum' => 'Kdyby\\Doctrine\\Types\\Enum', + 'test' => 'KdybyTests\\DoctrineMocks\\TestTypeMock', ]); $platform = $conn->getDatabasePlatform(); - Assert::same('enum', $platform->getDoctrineTypeMapping('enum')); + Assert::same('test', $platform->getDoctrineTypeMapping('test')); } } diff --git a/src/Kdyby/Doctrine/Types/Enum.php b/tests/KdybyTests/DoctrineMocks/TestTypeMock.php similarity index 87% rename from src/Kdyby/Doctrine/Types/Enum.php rename to tests/KdybyTests/DoctrineMocks/TestTypeMock.php index fa77ef6e..004f59af 100644 --- a/src/Kdyby/Doctrine/Types/Enum.php +++ b/tests/KdybyTests/DoctrineMocks/TestTypeMock.php @@ -8,19 +8,18 @@ * For the full copyright and license information, please view the file license.txt that was distributed with this source code. */ -namespace Kdyby\Doctrine\Types; +namespace KdybyTests\DoctrineMocks; use Doctrine; use Doctrine\DBAL\Platforms\AbstractPlatform; use Kdyby; -use Nette; /** * @author Filip Procházka */ -class Enum extends Kdyby\Doctrine\DbalType +class TestTypeMock extends Doctrine\DBAL\Types\Type { /** @@ -44,7 +43,7 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla */ public function getName() { - return Kdyby\Doctrine\DbalType::ENUM; + return 'test'; } }