summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2022-06-03 12:13:10 +0200
committerMike Bayer <mike_mp@zzzcomputing.com>2022-06-04 12:02:49 -0400
commit526e9bb6ae025d3b8032d6efc1deb1a0f4a3dae3 (patch)
treec0ccb7d6ca955af37ed618e890cf31157e0f3839 /test
parentad86d32f7fbd1c6deda8ff3bebe0595c0f2986cc (diff)
downloadsqlalchemy-526e9bb6ae025d3b8032d6efc1deb1a0f4a3dae3.tar.gz
Fixed orm not applying fetch
Fixed an issue where :meth:`_sql.GenerativeSelect.fetch` would be ignored when executing a statement using the ORM. Fixes: #8091 Change-Id: I6790c7272a71278e90de2529c8bc8ae89e54e288
Diffstat (limited to 'test')
-rw-r--r--test/orm/test_core_compilation.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/orm/test_core_compilation.py b/test/orm/test_core_compilation.py
index 631509ca0..19b1c34b1 100644
--- a/test/orm/test_core_compilation.py
+++ b/test/orm/test_core_compilation.py
@@ -304,6 +304,36 @@ class SelectableTest(QueryTest, AssertsCompiledSQL):
stmt = testing.resolve_lambda(stmt, **lambda_args)
self.assert_compile(stmt, expected)
+ def test_limit_offset_select(self):
+ User = self.classes.User
+
+ stmt = select(User.id).limit(5).offset(6)
+ self.assert_compile(
+ stmt,
+ "SELECT users.id FROM users LIMIT :param_1 OFFSET :param_2",
+ checkparams={"param_1": 5, "param_2": 6},
+ )
+
+ @testing.combinations(
+ (None, "ROWS ONLY"),
+ ({"percent": True}, "PERCENT ROWS ONLY"),
+ ({"percent": True, "with_ties": True}, "PERCENT ROWS WITH TIES"),
+ )
+ def test_fetch_offset_select(self, options, fetch_clause):
+ User = self.classes.User
+
+ if options is None:
+ stmt = select(User.id).fetch(5).offset(6)
+ else:
+ stmt = select(User.id).fetch(5, **options).offset(6)
+
+ self.assert_compile(
+ stmt,
+ "SELECT users.id FROM users OFFSET :param_1 "
+ "ROWS FETCH FIRST :param_2 %s" % (fetch_clause,),
+ checkparams={"param_1": 6, "param_2": 5},
+ )
+
class ColumnsClauseFromsTest(QueryTest, AssertsCompiledSQL):
__dialect__ = "default"