Commit 5308f084 authored by Padraig O'Sullivan's avatar Padraig O'Sullivan Committed by Benjamin Eberlei

Update fix for issue with bigint type to work for both postgresql and mysql.

parent 0251d10f
...@@ -45,4 +45,22 @@ class BigIntType extends Type ...@@ -45,4 +45,22 @@ class BigIntType extends Type
{ {
return \PDO::PARAM_STR; return \PDO::PARAM_STR;
} }
/**
* {@inheritdoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if (null === $value) {
return $value;
}
/*
* PostgreSQL detects 32 vs 64 bit systems and casts correctly
* for bigint types.
*/
if ($platform->getName() === 'postgresql' && PHP_INT_SIZE !== 4) {
return (string) $value;
}
return $value;
}
} }
...@@ -48,13 +48,12 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -48,13 +48,12 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$obj = new \stdClass(); $obj = new \stdClass();
$obj->foo = "bar"; $obj->foo = "bar";
$obj->bar = "baz"; $obj->bar = "baz";
$bigIntExpectedPhpType = (PHP_INT_SIZE === 4) ? 'string' : 'int';
return array( return array(
array('string', 'ABCDEFGaaaBBB', 'string'), array('string', 'ABCDEFGaaaBBB', 'string'),
array('boolean', true, 'bool'), array('boolean', true, 'bool'),
array('boolean', false, 'bool'), array('boolean', false, 'bool'),
array('bigint', 12345678, $bigIntExpectedPhpType), array('bigint', 12345678, 'string'),
array('smallint', 123, 'int'), array('smallint', 123, 'int'),
array('datetime', new \DateTime('2010-04-05 10:10:10'), 'DateTime'), array('datetime', new \DateTime('2010-04-05 10:10:10'), 'DateTime'),
array('datetimetz', new \DateTime('2010-04-05 10:10:10'), 'DateTime'), array('datetimetz', new \DateTime('2010-04-05 10:10:10'), 'DateTime'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment