IDENTITY() function hydrate data as string even if entity is configured as int #6546

Closed
opened 2026-01-22 15:34:51 +01:00 by admin · 3 comments
Owner

Originally created by @jdeniau on GitHub (Sep 22, 2020).

Given the following request

$qb = $this->createQueryBuilder('cartitem')
    ->select('IDENTITY(cartitem.cart) as cartId')
    ->getQuery()
    ->getArrayResult()
;

The return will be :

[
  1 => array:1 [
    "cartId" => "8982"
  ]
]

The cart id is hydrated as a string, but should be an integer.

If I changed the request to this:

$qb = $this->createQueryBuilder('cartitem')
    ->select('cart.id as cartId')
    ->join('cartitem.cart', 'cart')
    ->getQuery()
    ->getArrayResult()

The result is a int (which is normal)

Originally created by @jdeniau on GitHub (Sep 22, 2020). Given the following request ```php $qb = $this->createQueryBuilder('cartitem') ->select('IDENTITY(cartitem.cart) as cartId') ->getQuery() ->getArrayResult() ; ``` The return will be : ``` [ 1 => array:1 [ "cartId" => "8982" ] ] ``` The cart id is hydrated as a string, but should be an integer. If I changed the request to this: ```php $qb = $this->createQueryBuilder('cartitem') ->select('cart.id as cartId') ->join('cartitem.cart', 'cart') ->getQuery() ->getArrayResult() ``` The result is a int (which is normal)
admin closed this issue 2026-01-22 15:34:52 +01:00
Author
Owner

@SenseException commented on GitHub (Sep 22, 2020):

There's a PR that handles this issue: #8025

@SenseException commented on GitHub (Sep 22, 2020): There's a PR that handles this issue: #8025
Author
Owner

@jdeniau commented on GitHub (Sep 22, 2020):

@SenseException Great ! I looked in the issues but not in the PR.

I keep it open the time this PR is merged to avoid anyone to open the same issue 😉

@jdeniau commented on GitHub (Sep 22, 2020): @SenseException Great ! I looked in the issues but not in the PR. I keep it open the time this PR is merged to avoid anyone to open the same issue 😉
Author
Owner

@SenseException commented on GitHub (Sep 22, 2020):

If you don't mind I'll close this issue because it's a duplicate of #4641.

Still: Thank you for taking your time to report this.

@SenseException commented on GitHub (Sep 22, 2020): If you don't mind I'll close this issue because it's a duplicate of #4641. Still: Thank you for taking your time to report this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6546