From c27a038fc5905508498b87bfbc04a9bdf1b51a53 Mon Sep 17 00:00:00 2001 From: Syngnat <92659908+Syngnat@users.noreply.github.com> Date: Wed, 8 Jul 2026 11:08:03 +0800 Subject: [PATCH] test(query-result): auto limit cap has exact page total --- .../src/utils/queryResultPagination.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/utils/queryResultPagination.test.ts b/frontend/src/utils/queryResultPagination.test.ts index e84c152d..cff1e8f2 100644 --- a/frontend/src/utils/queryResultPagination.test.ts +++ b/frontend/src/utils/queryResultPagination.test.ts @@ -26,6 +26,25 @@ describe('queryResultPagination', () => { }); }); + it('treats query-editor injected LIMIT as a capped page rather than an uncounted total', () => { + const page = createInitialQueryResultPagination({ + executedSql: 'SELECT id, name FROM users LIMIT 500', + exportSql: 'SELECT id, name FROM users', + dbType: 'mysql', + returnedRowCount: 500, + fallbackPageSize: 500, + }); + + expect(page).toMatchObject({ + current: 1, + pageSize: 500, + total: 500, + totalKnown: true, + baseSql: 'SELECT id, name FROM users', + exportAllSql: 'SELECT id, name FROM users', + }); + }); + it('builds the next page SQL with one lookahead row', () => { expect(buildQueryResultPageSql({ baseSql: 'SELECT id FROM users',