Skip to content

Commit

Permalink
Merge pull request #251 from foxycode/drop-enum
Browse files Browse the repository at this point in the history
Drop ENUM type
  • Loading branch information
fprochazka committed Mar 14, 2016
2 parents 480bd55 + a186550 commit 0a3f027
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 44 deletions.
11 changes: 5 additions & 6 deletions src/Kdyby/Doctrine/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Doctrine;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Driver;
use Kdyby;
use Nette;
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions src/Kdyby/Doctrine/DI/OrmExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ class OrmExtension extends Nette\DI\CompilerExtension
'platformService' => NULL,
'defaultTableOptions' => [],
'resultCache' => 'default',
'types' => [
'enum' => 'Kdyby\Doctrine\Types\Enum',
],
'types' => [],
'schemaFilter' => NULL,
];

Expand Down
27 changes: 0 additions & 27 deletions src/Kdyby/Doctrine/DbalType.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/Kdyby/Doctrine/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Kdyby;
use Nette;
use Doctrine\DBAL\Types\Type;



Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tests/KdybyTests/Doctrine/Connection.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <filip@prochazka.su>
*/
class Enum extends Kdyby\Doctrine\DbalType
class TestTypeMock extends Doctrine\DBAL\Types\Type
{

/**
Expand All @@ -44,7 +43,7 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla
*/
public function getName()
{
return Kdyby\Doctrine\DbalType::ENUM;
return 'test';
}

}

0 comments on commit 0a3f027

Please sign in to comment.