Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop ENUM type #251

Merged
merged 1 commit into from
Mar 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>
*/
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';
}

}