def time_spent(self):
    return sum((i.time_spent for i in self.intervals), timedelta(0))

@time_spent.expression
def hours_spent(cls):
    return select([func.sum(Interval.time_spent)]).where(cls.id == Interval
        .task_id).label('time_spent')
How do I implement a null coalescing operator in SQLAlchemy?