Пример #1
0
    def test_last(self):
        rows = self.context.session.query(
            TaskEvent.assignee,
            last.of(TaskEvent.assignee),
        ).order_by(TaskEvent.clock.desc(), ).all()

        assert_that(
            rows,
            contains(
                contains(None, "Bob"),
                contains("Bob", "Bob"),
                contains(None, "Alice"),
                contains("Alice", "Alice"),
                contains(None, None),
            ))
Пример #2
0
    def test_last_filter_by(self):
        rows = self.context.session.query(
            TaskEvent.assignee,
            last.of(
                TaskEvent.assignee,
                TaskEvent.event_type == TaskEventType.ASSIGNED,
            ),
        ).order_by(TaskEvent.clock.desc(), ).all()

        assert_that(
            rows,
            contains(
                contains(None, "Alice"),
                contains("Bob", "Alice"),
                contains(None, "Alice"),
                contains("Alice", "Alice"),
                contains(None, None),
            ))
Пример #3
0
    def _aggregate(self, **kwargs):
        aggregate = super()._aggregate(**kwargs)
        aggregate.update(assignee=last.of(SubTaskEvent.assignee), )

        return aggregate
Пример #4
0
 def _aggregate(self, **kwargs):
     aggregate = super()._aggregate(**kwargs)
     aggregate.update(
         event_type=last.of(SimpleTestObjectEvent.event_type),
     )
     return aggregate