Orm: Broken lt, gt comparisons with dates

Created on 24 May 2018  路  4Comments  路  Source: doctrine/orm

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

Most helpful comment

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

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

All 4 comments

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

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).

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexander-schranz picture alexander-schranz  路  3Comments

weaverryan picture weaverryan  路  3Comments

doctrinebot picture doctrinebot  路  4Comments

strayobject picture strayobject  路  4Comments

delboy1978uk picture delboy1978uk  路  3Comments