Doctrine\ORM\QueryBuilder::setParameter and ArrayParameterType in DBAL 4.0.0 #7329

Closed
opened 2026-01-22 15:50:02 +01:00 by admin · 2 comments
Owner

Originally created by @hanishsingla on GitHub (Feb 20, 2024).

BC Break Report

Q A
BC Break yes
Version 3.0.0

Summary

Doctrine\ORM\QueryBuilder::setParameter() needs an optional parameter for complex data types sometimes and in 3.x version, it expects string|int|null and can be linked via Doctrine\DBAL\Connection e.g. Doctrine\DBAL\Connection::PARAM_STR_ARRAY. These values used to be as int datatype and have been deprecated. Now these constants are linked to Doctrine\DBAL\ArrayParameterType class. In 4.0.0 class ArrayParameterType has been converted to Enums but setParameter() is still accepting old string|int|null resulting following error

More info at https://github.com/doctrine/dbal/issues/6309

Originally created by @hanishsingla on GitHub (Feb 20, 2024). <!-- Before reporting a BC break, please consult the upgrading document to make sure it's not an expected change: https://github.com/doctrine/orm/blob/2.9.x/UPGRADE.md --> ### BC Break Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes | Version | 3.0.0 #### Summary <!-- Provide a summary describing the problem you are experiencing. --> `Doctrine\ORM\QueryBuilder::setParameter()` needs an optional parameter for complex data types sometimes and in 3.x version, it expects `string|int|null` and can be linked via `Doctrine\DBAL\Connection` e.g. `Doctrine\DBAL\Connection::PARAM_STR_ARRAY`. These values used to be as int datatype and have been deprecated. Now these constants are linked to `Doctrine\DBAL\ArrayParameterType` class. In 4.0.0 class ArrayParameterType has been converted to Enums but setParameter() is still accepting old `string|int|null` resulting following error More info at https://github.com/doctrine/dbal/issues/6309
admin added the Bug label 2026-01-22 15:50:02 +01:00
admin closed this issue 2026-01-22 15:50:02 +01:00
Author
Owner

@greg0ire commented on GitHub (Feb 20, 2024):

It would be nice to have a stack trace showing the issue.

@greg0ire commented on GitHub (Feb 20, 2024): It would be nice to have [a stack trace](https://symfony.com/doc/current/contributing/code/stack_trace.html) showing the issue.
Author
Owner

@hanishsingla commented on GitHub (Feb 20, 2024):

TypeError:
Doctrine\ORM\QueryBuilder::setParameter(): Argument #3 ($type) must be of type string|int|null, Doctrine\DBAL\ArrayParameterType given, called in {PROJECT_DIR_FILE} on line 77

  at {PROJECT_DIR}\vendor\doctrine\orm\src\QueryBuilder.php:436
  at Doctrine\ORM\QueryBuilder->setParameter('Ids', array('018da76a-a3f5-73bd-8fe4-0e62c9faca5d', '018da76a-260b-7847-9b44-07202c8be723', '1ecf9406-1bf1-6862-8d92-db4d4c006aaf', 'e2550bdb-abc7-11eb-9aa8-42010aa40fc4', 'c11b2a30-7797-11eb-9889-42010aa40fc4', '774b228a-764c-11eb-9889-42010aa40fc4', 'f03f5a14-6124-11eb-8152-42010aa40fc4', '4b3f0e62-83e1-11ea-a8ac-42010aa40fc4'), object(ArrayParameterType))

Code to Reproduce

return $this->createQueryBuilder('t')
	->where('t.id IN (:Ids)')
	->setParameter('Ids', $Ids, ArrayParameterType::STRING)
	->getQuery()
	->getResult();
@hanishsingla commented on GitHub (Feb 20, 2024): ``` TypeError: Doctrine\ORM\QueryBuilder::setParameter(): Argument #3 ($type) must be of type string|int|null, Doctrine\DBAL\ArrayParameterType given, called in {PROJECT_DIR_FILE} on line 77 at {PROJECT_DIR}\vendor\doctrine\orm\src\QueryBuilder.php:436 at Doctrine\ORM\QueryBuilder->setParameter('Ids', array('018da76a-a3f5-73bd-8fe4-0e62c9faca5d', '018da76a-260b-7847-9b44-07202c8be723', '1ecf9406-1bf1-6862-8d92-db4d4c006aaf', 'e2550bdb-abc7-11eb-9aa8-42010aa40fc4', 'c11b2a30-7797-11eb-9889-42010aa40fc4', '774b228a-764c-11eb-9889-42010aa40fc4', 'f03f5a14-6124-11eb-8152-42010aa40fc4', '4b3f0e62-83e1-11ea-a8ac-42010aa40fc4'), object(ArrayParameterType)) ``` **Code to Reproduce** ``` return $this->createQueryBuilder('t') ->where('t.id IN (:Ids)') ->setParameter('Ids', $Ids, ArrayParameterType::STRING) ->getQuery() ->getResult(); ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7329