doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.86k stars 2.5k forks source link

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

Open VincentLanglet opened 4 days ago

VincentLanglet commented 4 days ago

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)