def test_group_by_query(self):
table = self.create_table()
query = session.query(table.c.x).group_by(table.c.x)
self.assertEqual(
self.compile(query),
'SELECT x AS t1_x FROM t1 GROUP BY x'
)
query = session.query(table.c.x).group_by(table.c.x).with_totals()
self.assertEqual(
self.compile(query),
'SELECT x AS t1_x FROM t1 GROUP BY x WITH TOTALS'
)
with self.assertRaises(exc.InvalidRequestError) as ex:
session.query(table.c.x).with_totals()
self.assertIn('with_totals', str(ex.exception))
评论列表
文章目录