Cannot findBy with a string on a DateTime field since 2.20.7 #7584

Open
opened 2026-01-22 15:53:52 +01:00 by admin · 2 comments
Owner

Originally created by @lou-perret on GitHub (Jan 9, 2026).

Bug Report

Q A
Version 2.20.7 (still happening in 2.20.9)
Previous Version if the bug is a regression 2.20.6

Summary

Hello !

Since the 2.20.7 update, it looks like we cannot do a "findBy" on a Doctrine\DBAL\Types\Types\Types::TIME_IMMUTABLE (or DATE_MUTABLE) field with strings anymore

Replacing the strings with \DateTimeImmutable does the trick

Current behavior

Create an entity with

	#[ORM\Column(type: Types::DATE_IMMUTABLE)]
	private ?\DateTimeImmutable $date = null;

Use it like this

$this->em->getRepository(MyEntity::class)->findBy(['date' => '2025-02-04']);
Could not convert PHP value '2025-02-04' to type date_immutable. Expected one of the following types: null, DateTimeImmutable

 trace: {
        /vendor/doctrine/dbal/src/Types/ConversionException.php:78 { …}
        /vendor/doctrine/dbal/src/Types/DateImmutableType.php:41 { …}
        /vendor/doctrine/dbal/src/Connection.php:1887 { …}
        /vendor/doctrine/dbal/src/Connection.php:1828 { …}
        /vendor/doctrine/dbal/src/Connection.php:1102 { …}
        /vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:995 { …}
        /vendor/doctrine/orm/src/EntityRepository.php:224 { …}

Expected behavior

I should get an array with every MyEntity with the date of 2025-02-04

Originally created by @lou-perret on GitHub (Jan 9, 2026). ### Bug Report | Q | A |-------------------------------------------- | ------ | Version | 2.20.7 (still happening in 2.20.9) | Previous Version if the bug is a regression | 2.20.6 #### Summary Hello ! Since the 2.20.7 update, it looks like we cannot do a "findBy" on a Doctrine\DBAL\Types\Types\Types::TIME_IMMUTABLE (or DATE_MUTABLE) field with strings anymore Replacing the strings with \DateTimeImmutable does the trick #### Current behavior Create an entity with ``` #[ORM\Column(type: Types::DATE_IMMUTABLE)] private ?\DateTimeImmutable $date = null; ``` Use it like this ``` $this->em->getRepository(MyEntity::class)->findBy(['date' => '2025-02-04']); ``` ``` Could not convert PHP value '2025-02-04' to type date_immutable. Expected one of the following types: null, DateTimeImmutable trace: { /vendor/doctrine/dbal/src/Types/ConversionException.php:78 { …} /vendor/doctrine/dbal/src/Types/DateImmutableType.php:41 { …} /vendor/doctrine/dbal/src/Connection.php:1887 { …} /vendor/doctrine/dbal/src/Connection.php:1828 { …} /vendor/doctrine/dbal/src/Connection.php:1102 { …} /vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:995 { …} /vendor/doctrine/orm/src/EntityRepository.php:224 { …} ``` #### Expected behavior I should get an array with every MyEntity with the date of 2025-02-04
Author
Owner
@HeahDude commented on GitHub (Jan 9, 2026): The culprit seems to be https://github.com/doctrine/orm/pull/11895/files#diff-3ca09663ec045c8f6549f5960c6cf11c38a839c46eb6efb2151c0c00498e3045.
Author
Owner

@HeahDude commented on GitHub (Jan 9, 2026):

Possibly relates to https://github.com/doctrine/orm/issues/12245.

@HeahDude commented on GitHub (Jan 9, 2026): Possibly relates to https://github.com/doctrine/orm/issues/12245.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7584