Here are the examples of the python api sqlalchemy.union.limit taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Example 1
Project: sqlalchemy Source File: test_select.py
@testing.requires.parens_in_union_contained_select_w_limit_offset
def test_limit_offset_selectable_in_unions(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
limit(1).order_by(table.c.id)
s2 = select([table]).where(table.c.id == 3).\
limit(1).order_by(table.c.id)
u1 = union(s1, s2).limit(2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
3
Example 2
Project: sqlalchemy Source File: test_select.py
@testing.requires.parens_in_union_contained_select_wo_limit_offset
def test_order_by_selectable_in_unions(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
order_by(table.c.id)
s2 = select([table]).where(table.c.id == 3).\
order_by(table.c.id)
u1 = union(s1, s2).limit(2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
3
Example 3
Project: sqlalchemy Source File: test_select.py
def test_distinct_selectable_in_unions(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
distinct()
s2 = select([table]).where(table.c.id == 3).\
distinct()
u1 = union(s1, s2).limit(2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
3
Example 4
Project: sqlalchemy Source File: test_select.py
def test_limit_offset_aliased_selectable_in_unions(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
limit(1).order_by(table.c.id).alias().select()
s2 = select([table]).where(table.c.id == 3).\
limit(1).order_by(table.c.id).alias().select()
u1 = union(s1, s2).limit(2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)