Argument #1 ($sql) must be of type string, null given #7246

Closed
opened 2026-01-22 15:48:06 +01:00 by admin · 1 comment
Owner

Originally created by @mikaeldelsol on GitHub (Nov 17, 2023).

BC Break Report

Q A
BC Break yes
Version 2.17.0

Summary

Previous behavior

public function findDuplicates(string $anyId, string $anyService, ?string $id = null)
{
    $qb = $this->createQueryBuilder('e');
    $qb->where('t.anyId = :any_id')
        ->andWhere('t.anyService = :any_service')
        ->setParameter('any_id', $anyId, Types::STRING)
        ->setParameter('any_service', $anyService, Types::STRING)
    ;
    if (null !== $id) {
        $qb->andWhere('t.id <> :id')->setParameter('id', $id, Types::STRING);
    }

    return $qb->getQuery()->getResult();
}

Normally returns an array, empty or not.

Current behavior

Running this same code produces this error:

Uncaught PHP Exception TypeError: "Doctrine\DBAL\Connection::executeQuery(): Argument #1 ($sql) must be of type string,
null given, called in /app/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php on line 33"
at /app/vendor/doctrine/dbal/src/Connection.php line 1071

From what I observed, the SingleSelectExecutor::__construct method is not called.

How to reproduce

Both case:

  • no opcache
  • no apc cache
  • project build with docker and deployed in a kubernetes cluster

Working case:
doctrine/orm:2.16.2

Broken case:
doctrine/orm:2.17.0

How to "fix"

Run command bin/console cache:clear

From what I observed, the SingleSelectExecutor::__construct method is then called.

Originally created by @mikaeldelsol on GitHub (Nov 17, 2023). <!-- 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 | 2.17.0 #### Summary <!-- Provide a summary describing the problem you are experiencing. --> #### Previous behavior <!-- What was the previous (working) behavior? --> ```php public function findDuplicates(string $anyId, string $anyService, ?string $id = null) { $qb = $this->createQueryBuilder('e'); $qb->where('t.anyId = :any_id') ->andWhere('t.anyService = :any_service') ->setParameter('any_id', $anyId, Types::STRING) ->setParameter('any_service', $anyService, Types::STRING) ; if (null !== $id) { $qb->andWhere('t.id <> :id')->setParameter('id', $id, Types::STRING); } return $qb->getQuery()->getResult(); } ``` Normally returns an array, empty or not. #### Current behavior <!-- What is the current (broken) behavior? --> Running this same code produces this error: ``` Uncaught PHP Exception TypeError: "Doctrine\DBAL\Connection::executeQuery(): Argument #1 ($sql) must be of type string, null given, called in /app/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php on line 33" at /app/vendor/doctrine/dbal/src/Connection.php line 1071 ``` From what I observed, the SingleSelectExecutor::__construct method is not called. #### How to reproduce <!-- Provide steps to reproduce the BC break. If possible, also add a code snippet with relevant configuration, entity mappings, DQL etc. Adding a failing Unit or Functional Test would help us a lot - you can submit it in a Pull Request separately, referencing this bug report. --> Both case: - no opcache - no apc cache - project build with docker and deployed in a kubernetes cluster Working case: doctrine/orm:2.16.2 Broken case: doctrine/orm:2.17.0 #### How to "fix" Run command `bin/console cache:clear` From what I observed, the SingleSelectExecutor::__construct method is then called.
admin added the Bug label 2026-01-22 15:48:06 +01:00
admin closed this issue 2026-01-22 15:48:06 +01:00
Author
Owner

@greg0ire commented on GitHub (Nov 17, 2023):

Please only make bug reports for the latest possible versions. 2.17.1 is out (and fixes your bug).

@greg0ire commented on GitHub (Nov 17, 2023): Please only make bug reports for the latest possible versions. 2.17.1 is out (and fixes your bug).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7246