dbal
dbal copied to clipboard
Allow (also for DATETIME) dynamic intervals in DATE_ADD & DATE_SUB for SQLite
Bug Report
This issue is related to #2983. Currently, DATE_ADD & DATE_SUB with interpolated interval is only available for DATE.
| Q | A |
|---|---|
| Version | 3.7.2 |
Summary
Exemple code :
<?php
$rp
->createQueryBuilder('s')
->select('s')
->leftJoin('s.agency', 'sAg')
->where("s.endAt < DATE_ADD(NOW(), sAg.utcOffset, 'minute')")
;
Current behaviour
The previous exemple produce the following SQL query :
SELECT s0_.id AS id_0, s0_.end_at AS end_at_6
FROM services s0_
LEFT JOIN companies c1_ ON s0_.agency_id = c1_.id
WHERE s0_.end_at < DATETIME(?,'+c1_.utc_offset MINUTE')
And won't return any result (invalid DATETIME comparison)
How to reproduce
Run the exemple in any database.
Expected behaviour
Inspired from the mentionned issue #2983 and related merge request, doctrine may have produce the following SQL with concat operator :
SELECT s0_.id AS id_0, s0_.end_at AS end_at_6
FROM services s0_
LEFT JOIN companies c1_ ON s0_.agency_id = c1_.id
WHERE s0_.end_at < DATETIME(?,'+' || c1_.utc_offset || ' MINUTE')
I will create a merge request to introduce a fix.
Thanks for your great work.