Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-83

BigInt Type is returning string instead of integer

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      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.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        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

        Show
        Benjamin Eberlei added a comment - 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
        Hide
        Giovanni Lovato added a comment -

        This behavior can't be correct:

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

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

        Show
        Giovanni Lovato added a comment - This behavior can't be correct: php > var_dump($object->id); int(201308090001) php > $em->persist($object); php > var_dump($em->find(get_class($object), 201308090001)->id); string("201308090001"); The type should be consistent no matter what, otherwise the idempotent requirement breaks.
        Hide
        Benjamin Eberlei added a comment -

        Giovanni Lovato This was fixed, bigint identity generation will always work with strings.

        Show
        Benjamin Eberlei added a comment - Giovanni Lovato This was fixed, bigint identity generation will always work with strings.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Miloslav "adrive" Kmet
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: