Changing the hydration mode doesn't give the same type of result for BigInt #7389

Open
opened 2026-01-22 15:51:07 +01:00 by admin · 0 comments
Owner

Originally created by @VincentLanglet on GitHub (Jun 26, 2024).

Bug Report

Q A
BC Break no
Version 2.19

Summary

Hi.

I'm note sure if it's a bug or a wanted behavior (and for what reason) but the type of a bigint value is return by a query is different when changing the Hydration mode. Let's take

Current behavior

With HYDRATE_OBJECT or HYDRATE_ARRAY I'm getting ["42"],
but with HYDRATE_SCALAR or HYDRATE_SINGLE_SCALAR, I'm getting [42]and withHYDRATE_SCALAR_COLUMNI'm getting42`.

How to reproduce

$this->createQueryBuilder('d')
            ->select('d.id') // where the id is a bigInt field
            ->setMaxResults(1)
            ->getQuery()
            ->getSingleResult();

Expected behavior

I would expect to get "42" everytime (in DBAL 3).

This is kinda fixed by DBAL 4 where int will be the type of value in HYDRATE_OBJECT or HYDRATE_ARRAY if think for bigInt.
But I wonder, if this happen for bigint in DBAL 3, this might happen for some other value/type. This would require investigation but I prefer first to know if it's considered as a bug or done by design.

Is there a valid reason for not having basically

HYDRATE_SCALAR_COLUMN = array_column(HYDRATE_ARRAY, 0)
Originally created by @VincentLanglet on GitHub (Jun 26, 2024). ### Bug Report | Q | A |------------ | ------ | BC Break | no | Version | 2.19 #### Summary Hi. I'm note sure if it's a bug or a wanted behavior (and for what reason) but the type of a bigint value is return by a query is different when changing the Hydration mode. Let's take #### Current behavior With `HYDRATE_OBJECT` or `HYDRATE_ARRAY` I'm getting `["42"]`, but with `HYDRATE_SCALAR` or `HYDRATE_SINGLE_SCALAR, I'm getting `[42]` and with `HYDRATE_SCALAR_COLUMN` I'm getting `42`. #### How to reproduce ``` $this->createQueryBuilder('d') ->select('d.id') // where the id is a bigInt field ->setMaxResults(1) ->getQuery() ->getSingleResult(); ``` #### Expected behavior I would expect to get `"42"` everytime (in DBAL 3). This is kinda fixed by DBAL 4 where `int` will be the type of value in `HYDRATE_OBJECT` or `HYDRATE_ARRAY` if think for bigInt. But I wonder, if this happen for bigint in DBAL 3, this might happen for some other value/type. This would require investigation but I prefer first to know if it's considered as a bug or done by design. Is there a valid reason for not having basically ``` HYDRATE_SCALAR_COLUMN = array_column(HYDRATE_ARRAY, 0) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7389