mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1282: getDateAddDaysExpression() casts $days to integer preventing column based add expressions. #1612
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jul 20, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user spiffyjr:
Take the following:
Which generates the DQL: SELECT partial a.{dsid,rid,activeStartDate} FROM VetLogic\Entity\Appointment a LEFT JOIN a.clinic c LEFT JOIN a.patient p WHERE c.autoAppointmentReminders = 1 AND a.enabled = 1 AND a.activeStartDate = DATE_ADD(CURRENT_DATE(), c.appointmentRemindersDaysInAdvance, 'day')
And SQL: SELECT a0_.rid AS rid0, a0_.dsid AS dsid1, a0_.activeStartDate AS activeStartDate2, a0_.dsid AS dsid3, a0_.dsid AS dsid4, a0_.clinicRid AS clinicRid5, a0_.dsid AS dsid6, a0_.patientRid AS patientRid7, a0_.dsid AS dsid8, a0_.rid AS rid9 FROM appointment a0_ LEFT JOIN clinic c1_ ON a0_.dsid = c1_.dsid AND a0_.clinicRid = c1_.rid LEFT JOIN patient p2_ ON a0_.dsid = p2_.dsid AND a0_.patientRid = p2_.rid WHERE c1_.autoAppointmentReminders = 1 AND a0_.enabled = 1 AND a0_.activeStartDate = DATE_ADD(CURRENT_DATE, INTERVAL0 DAY)
The DATE_ADD(CURRENT_DATE, INTERVAL0 DAY) is generated incorrectly because getDateAddDaysExpression($date, $days) casts $days to an integer.
The fix is simply to remove (int) from return 'DATE_ADD(' . $date . ', INTERVAL ' . (int)$days . ' DAY)';
Note: I only checked the MySQL platform so I'm not sure if other platforms are affected.