Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow (also for DATETIME) dynamic intervals in DATE_ADD & DATE_SUB for SQLite #6261

Open
DaedalusDev opened this issue Jan 12, 2024 · 0 comments

Comments

@DaedalusDev
Copy link

DaedalusDev commented Jan 12, 2024

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.

DaedalusDev added a commit to DaedalusDev/dbal that referenced this issue Jan 12, 2024
…in DATE_ADD & DATE_SUB for SQLite

- 🐛 Fix code divergence
- ✅ Add related tests
DaedalusDev added a commit to DaedalusDev/dbal that referenced this issue Jan 12, 2024
…in DATE_ADD & DATE_SUB for SQLite

- 🐛 Fix code divergence
- ✅ Add related tests
DaedalusDev added a commit to DaedalusDev/dbal that referenced this issue Jan 26, 2024
…in DATE_ADD & DATE_SUB for SQLite

- ✅ Add related functional test
DaedalusDev added a commit to DaedalusDev/dbal that referenced this issue Jan 26, 2024
…in DATE_ADD & DATE_SUB for SQLite

- 👌 Code review from @derrabus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant