doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.91k stars 2.51k forks source link

DDC-3291: Cannot use eq expression for comparison of DateTime #4083

Open doctrinebot opened 10 years ago

doctrinebot commented 10 years ago

Jira issue originally created by user sparrowek:

When I use return ArrayCollection::matching() with criteria defined with eq expression like that: Criteria::create()->where(Criteria::expr()->eq('day', $day)) I get no results since equality operator uses === comparison which will almost always return false for objects. The only way I found to get around this is to use in operator instead Criteria::create()->where(Criteria::expr()->in('day', array($day)))

jamesmoey commented 7 years ago

Any plan to add expression to compare date? Or a loose equal == instead of ===

Ocramius commented 7 years ago

No plans for that, and we won't add exceptions for custom scalar types, such as DateTime, so for now you will need to stick to DQL functions.