Skip to content


DDC-1282: getDateAddDaysExpression() casts $days to integer preventing column based add expressions. #1895

doctrinebot opened this Issue · 2 comments

2 participants


Jira issue originally created by user spiffyjr:

Take the following:

    $qb = $this->createQueryBuilder('a');
    $qb->select('partial a.{dsid,rid,activeStartDate}');
    $qb->leftJoin('', 'c');
    $qb->leftJoin('a.patient', 'p');
    $qb->where('c.autoAppointmentReminders = 1');
    $qb->andWhere('a.enabled = 1');
                "DATE*ADD(CURRENT*DATE(), c.appointmentRemindersDaysInAdvance, 'day')"));

Which generates the DQL: SELECT partial a.{dsid,rid,activeStartDate} FROM VetLogic\Entity\Appointment a LEFT JOIN c LEFT JOIN a.patient p WHERE c.autoAppointmentReminders = 1 AND a.enabled = 1 AND a.activeStartDate = DATEADD(CURRENTDATE(), 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(CURRENTDATE, INTERVAL0 DAY)

The DATEADD(CURRENTDATE, 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.


Comment created by @beberlei:



Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1.1 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.