mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Criteria works with DateTime arrays, but not DateTime objects #6884
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @andreas-aeschlimann on GitHub (Dec 6, 2021).
Bug Report
Summary
In my project, I am creating generic queries. I noticed that
Criteria::expr()->eq("expiration", new DateTime())does not work and throws the errorObject of class DateTime could not be converted to string. But oddly enough,Criteria::expr()->in("expiration", [new DateTime()])is working.I think the behavior should always be the same.
Note: Passing a string does not work either, it then says
Could not convert PHP value '2021-09-16 00:05:50' of type 'string' to type 'datetime'. Expected one of the following types: null, DateTime.Current behavior
See above
How to reproduce
See above
Expected behavior
It would be great if also non-array DateTimes could be used as criteria.