Skip to content

Loading…

DBAL-83: BigInt Type is returning string instead of integer #2064

Closed
doctrinebot opened this Issue · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user adrive:

I ran all tests with PostgreSQL and I got an error:

1) Doctrine\Tests\DBAL\Functional\TypeConversionTest::testIdempotentDataConversion with data set #3 ('bigint', 12345678, 'string')
The expected type from the conversion to and back from the database should be string
Failed asserting that <integer:12345678> is of type "string".

/usr/share/php/Doctrine2/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php:84

FAILURES!
Tests: 367, Assertions: 745, Failures: 1, Skipped: 8.

The BigInt Type is missing convertToPHPValue() method and returns string instead of int. I fixed this and also I fixed the test case for this. Patch will be availabe via github pull request.

@doctrinebot

Comment created by @beberlei:

Bigints have to be strings for int overflow reasons. PostgreSQL seems to detect 64 vs 32bit systems and casts correctly, this is unfortunate for the tests, i have to come up with a workdaround for this :-)

@doctrinebot

Issue was closed with resolution "Won't Fix"

@doctrinebot

Comment created by heruan:

This behavior can't be correct:

php > var_dump($object->id);
int(201308090001)
php > $em->persist($object);
php > vardump($em->find(getclass($object), 201308090001)->id);
string("201308090001");

The type should be consistent no matter what, otherwise the idempotent requirement breaks.

@doctrinebot

Comment created by @beberlei:

[~heruan] This was fixed, bigint identity generation will always work with strings.

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.