Map bigint DB type to "int" (not as DBAL historically does to "string")
[MAILPOET-2945]
This commit is contained in:
@@ -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,
|
||||
|
25
lib/Doctrine/Types/BigIntType.php
Normal file
25
lib/Doctrine/Types/BigIntType.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user