Пример #1
0
 def date_add(self, field, date_part, interval):
     # adding an extra 's' as MySQL's interval doesn't work with 'year', 'week' etc, it expects a plural
     interval_term = terms.Interval(**{
         '{}s'.format(str(date_part)): interval,
         'dialect': Dialects.MYSQL
     })
     return DateAdd(field, interval_term)
Пример #2
0
    def __init__(self, field, date_part, interval):
        wrapped_field = self.wrap_constant(field, PostgreSQLTimestamp)
        if date_part == "quarter":
            date_part = "month"
            interval *= 3

        interval_term = terms.Interval(**{
            f'{str(date_part)}s': interval,
            'dialect': Dialects.POSTGRESQL
        })
        super().__init__('DATEADD', wrapped_field, interval_term)