Broken lt, gt comparisons with dates #5974

Closed
opened 2026-01-22 15:23:47 +01:00 by admin · 4 comments
Owner

Originally created by @rmbl on GitHub (May 24, 2018).

BC Break Report

Q A
BC Break yes
Version 2.6.0

Summary

Query Builder Expressions are not behaving the same as before. We're trying to get all entities before a certain date using

$qb = $this->createQueryBuilder('site');
$query = $qb
    ->select('site')
    ->where($qb->expr()->lte('site.endDate', (new \DateTime())->format('Y-m-d')))
    ->getQuery();

Instead of comparing dates, the query builder seems to think, that it's a calculation which leads to very different results.

Previous behavior

SELECT * FROM site WHERE endDate <= '2018-05-24';

Current behavior

SELECT * FROM site WHERE endDate <= 2018 - 05 - 24;

How to reproduce

See code snippet above

Originally created by @rmbl on GitHub (May 24, 2018). ### BC Break Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes | Version | 2.6.0 #### Summary Query Builder Expressions are not behaving the same as before. We're trying to get all entities before a certain date using ```php $qb = $this->createQueryBuilder('site'); $query = $qb ->select('site') ->where($qb->expr()->lte('site.endDate', (new \DateTime())->format('Y-m-d'))) ->getQuery(); ``` Instead of comparing dates, the query builder seems to think, that it's a calculation which leads to very different results. #### Previous behavior ```sql SELECT * FROM site WHERE endDate <= '2018-05-24'; ``` #### Current behavior ```sql SELECT * FROM site WHERE endDate <= 2018 - 05 - 24; ``` #### How to reproduce See code snippet above
admin closed this issue 2026-01-22 15:23:48 +01:00
Author
Owner

@Ocramius commented on GitHub (May 24, 2018):

@rmbl what are the exact generated DQL strings before/after, and is it 2.6.0 exactly that broke this?

@Ocramius commented on GitHub (May 24, 2018): @rmbl what are the exact generated DQL strings before/after, and is it `2.6.0` exactly that broke this?
Author
Owner

@rmbl commented on GitHub (May 24, 2018):

We're currently using 2.6.1. I'll try it with all relevant versions later. Our customers only noticed the GDPR yesterday (or so it seems).

@rmbl commented on GitHub (May 24, 2018): We're currently using 2.6.1. I'll try it with all relevant versions later. Our customers only noticed the GDPR yesterday (or so it seems).
Author
Owner

@Ocramius commented on GitHub (May 24, 2018):

Our customers only noticed the GDPR yesterday (or so it seems).

https://youtu.be/G1WomfhjyVM?t=29

@Ocramius commented on GitHub (May 24, 2018): > Our customers only noticed the GDPR yesterday (or so it seems). https://youtu.be/G1WomfhjyVM?t=29
Author
Owner

@rmbl commented on GitHub (Jun 5, 2018):

I was unable to find a working version. Seems like that was always the behaviour and the previous developer was using the function wrong. No idea how that function ever worked.

@rmbl commented on GitHub (Jun 5, 2018): I was unable to find a working version. Seems like that was always the behaviour and the previous developer was using the function wrong. No idea how that function ever worked.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5974