From efcd5011fae7d8aa20ef8c78b1e16a7aa50f719f Mon Sep 17 00:00:00 2001 From: AarDG10 Date: Thu, 30 Apr 2026 11:09:47 +0530 Subject: [PATCH] test: add test for limit offset behavior --- frappe/tests/test_query.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frappe/tests/test_query.py b/frappe/tests/test_query.py index 58f41f1278..18ab24c332 100644 --- a/frappe/tests/test_query.py +++ b/frappe/tests/test_query.py @@ -2625,6 +2625,19 @@ class TestQuery(IntegrationTestCase): ) self.assertFalse(index_exists) + def test_limit_offset_query(self): + """Test if query builder correctly uses limit with offset in MariaDB and SQLite when limit is omitted.""" + from frappe.database.query import MAX_LIMIT + + query = frappe.qb.get_query("Doctype", offset=10).get_sql() + if frappe.db.db_type != "postgres": + self.assertIn(f"LIMIT {MAX_LIMIT} OFFSET 10", query) + query = frappe.qb.get_query("Doctype", limit=10, offset=10).get_sql() + self.assertIn("LIMIT 10 OFFSET 10", query) + else: + self.assertNotIn("LIMIT", query) + self.assertIn("OFFSET 10", query) + # This function is used as a permission query condition hook def test_permission_hook_condition(user):