fix(grid): separate table open row limit

This commit is contained in:
zipg authored and GitHub committed 2026-07-11 08:55:43 +08:00
1 parent 1d0d2fbc05
commit 343a5ba6c9
6 files changed
+59 -15

No files matched your search

+51 -5
View File
@@ -2412,7 +2412,7 @@ test("data tab execution preserves pagination offset metadata", async () => {
}
});
test("data tab default pagination follows persisted rows-per-page", async () => {
test("data tab default pagination is independent from query result page size", async () => {
const restoreStorage = installMemoryStorage();
setActivePinia(createPinia());
const connectionStore = useConnectionStore();
@@ -2445,12 +2445,12 @@ test("data tab default pagination follows persisted rows-per-page", async () =>
});
try {
await store.executeTabSql(tabId, 'SELECT * FROM "users" LIMIT 1000;');
await store.executeTabSql(tabId, 'SELECT * FROM "users" LIMIT 100;');
assert.equal(preparedPagination, false);
assert.equal(executeBody.maxRows, 1000);
assert.equal(executeBody.fetchSize, 1000);
assert.equal(tab.resultPageLimit, 1000);
assert.equal(executeBody.maxRows, 100);
assert.equal(executeBody.fetchSize, 100);
assert.equal(tab.resultPageLimit, 100);
assert.equal(tab.resultPageOffset, 0);
} finally {
globalThis.fetch = originalFetch;
@@ -2458,6 +2458,52 @@ test("data tab default pagination follows persisted rows-per-page", async () =>
}
});
test("reloading an evicted data tab preserves its saved pagination", async () => {
const restoreStorage = installMemoryStorage();
setActivePinia(createPinia());
const connectionStore = useConnectionStore();
const settingsStore = useSettingsStore();
const store = useQueryStore();
const originalFetch = globalThis.fetch;
let executeBody: any;
settingsStore.updateEditorSettings({ pageSize: 1000 });
connectionStore.addEphemeralConnection(conn("conn-1"));
const tabId = store.createTab("conn-1", "db", "users", "data", "public");
const tab = store.tabs.find((item) => item.id === tabId);
assert.ok(tab);
tab.sql = 'SELECT * FROM "public"."users" LIMIT 50 OFFSET 50;';
tab.lastExecutedSql = tab.sql;
tab.resultPageLimit = 50;
tab.resultPageOffset = 50;
tab.resultEvicted = true;
globalThis.fetch = withConnectionHealthMock(async (input, init) => {
const url = String(input);
if (url === "/api/query/execute-multi") {
executeBody = JSON.parse(String(init?.body ?? "{}"));
return new Response(JSON.stringify([{ columns: ["id"], rows: [[51]], affected_rows: 0, execution_time_ms: 1 }]), {
status: 200,
headers: { "Content-Type": "application/json" },
});
}
return new Response("unexpected request", { status: 500 });
});
try {
await store.reloadEvictedTab(tabId);
assert.equal(executeBody.maxRows, 50);
assert.equal(executeBody.fetchSize, 50);
assert.equal(tab.resultPageLimit, 50);
assert.equal(tab.resultPageOffset, 50);
assert.equal(tab.resultEvicted, undefined);
} finally {
globalThis.fetch = originalFetch;
restoreStorage();
}
});
test("activating an empty data tab waits for explicit execution", async () => {
const restoreStorage = installMemoryStorage();
setActivePinia(createPinia());