Map bigint DB type to "int" (not as DBAL historically does to "string")

[MAILPOET-2945]
This commit is contained in:
Jan Jakeš
2020-05-26 15:26:07 +02:00
committed by Veljko V
parent fb238cd531
commit e69188c5a0
2 changed files with 27 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
namespace MailPoet\Doctrine;
use MailPoet\Config\Env;
use MailPoet\Doctrine\Types\BigIntType;
use MailPoet\Doctrine\Types\JsonOrSerializedType;
use MailPoet\Doctrine\Types\JsonType;
use MailPoet\Doctrine\Types\SerializedArrayType;
@@ -18,6 +19,7 @@ class ConnectionFactory {
private $minWaitTimeout = 60;
private $types = [
BigIntType::NAME => BigIntType::class,
JsonType::NAME => JsonType::class,
JsonOrSerializedType::NAME => JsonOrSerializedType::class,
SerializedArrayType::NAME => SerializedArrayType::class,

View File

@@ -0,0 +1,25 @@
<?php
namespace MailPoet\Doctrine\Types;
use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform;
use MailPoetVendor\Doctrine\DBAL\Types\BigIntType as DoctrineBigIntType;
use PDO;
class BigIntType extends DoctrineBigIntType {
// override Doctrine's bigint type that historically maps DB's "bigint" to PHP's "string"
// (we want to map DB's "bigint" to PHP's "int" in today's 64-bit world)
const NAME = 'bigint';
public function getBindingType() {
return PDO::PARAM_INT;
}
public function convertToPHPValue($value, AbstractPlatform $platform) {
return $value === null ? null : (int)$value;
}
public function getName() {
return self::NAME;
}
}