test: add test for limit offset behavior

This commit is contained in:
AarDG10 2026-04-30 11:09:47 +05:30
parent d6adf919c9
commit efcd5011fa

View file

@ -2625,6 +2625,19 @@ class TestQuery(IntegrationTestCase):
) )
self.assertFalse(index_exists) 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 # This function is used as a permission query condition hook
def test_permission_hook_condition(user): def test_permission_hook_condition(user):