fix(grid): separate table open row limit
This commit is contained in:
6 files changed
+59
-15
No files matched your search
@@ -1306,7 +1306,7 @@ async function openData() {
|
|||||||
logPhase("ensure-connected", { tabId });
|
logPhase("ensure-connected", { tabId });
|
||||||
if (!config) throw new Error("Connection config not found");
|
if (!config) throw new Error("Connection config not found");
|
||||||
|
|
||||||
const limit = tableOpenPageLimit(settingsStore.editorSettings.pageSize);
|
const limit = tableOpenPageLimit();
|
||||||
const refreshTableMetaInBackground = async () => {
|
const refreshTableMetaInBackground = async () => {
|
||||||
const metadataStartedAt = performance.now();
|
const metadataStartedAt = performance.now();
|
||||||
console.info("[DBX][openData:metadata:start]", {
|
console.info("[DBX][openData:metadata:start]", {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
|
|||||||
const connectionStore = useConnectionStore();
|
const connectionStore = useConnectionStore();
|
||||||
const queryStore = useQueryStore();
|
const queryStore = useQueryStore();
|
||||||
const settingsStore = useSettingsStore();
|
const settingsStore = useSettingsStore();
|
||||||
const pageLimit = tableOpenPageLimit(settingsStore.editorSettings.pageSize);
|
const pageLimit = tableOpenPageLimit();
|
||||||
|
|
||||||
connectionStore.activeConnectionId = target.connectionId;
|
connectionStore.activeConnectionId = target.connectionId;
|
||||||
const config = connectionStore.getConfig(target.connectionId);
|
const config = connectionStore.getConfig(target.connectionId);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { DEFAULT_RESULT_PAGE_SIZE, normalizeResultPageSize } from "@/lib/dataGri
|
|||||||
|
|
||||||
export const DEFAULT_TABLE_OPEN_PAGE_LIMIT = DEFAULT_RESULT_PAGE_SIZE;
|
export const DEFAULT_TABLE_OPEN_PAGE_LIMIT = DEFAULT_RESULT_PAGE_SIZE;
|
||||||
|
|
||||||
export function tableOpenPageLimit(preferredLimit?: unknown): number {
|
export function tableOpenPageLimit(): number {
|
||||||
// Data tabs should reopen with the rows-per-page preference the grid persists.
|
// Opening a table should not inherit the mutable SQL result-grid rows-per-page setting.
|
||||||
return normalizeResultPageSize(preferredLimit, DEFAULT_TABLE_OPEN_PAGE_LIMIT);
|
return normalizeResultPageSize(DEFAULT_TABLE_OPEN_PAGE_LIMIT);
|
||||||
}
|
}
|
||||||
@@ -2694,7 +2694,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
countSql = plan.countSql;
|
countSql = plan.countSql;
|
||||||
useAgentResultSession = plan.useAgentResultSession;
|
useAgentResultSession = plan.useAgentResultSession;
|
||||||
} else if (tab.mode === "data") {
|
} else if (tab.mode === "data") {
|
||||||
pageLimit = options?.pagination?.limit ?? tableOpenPageLimit(settingsStore.editorSettings.pageSize);
|
pageLimit = options?.pagination?.limit ?? tableOpenPageLimit();
|
||||||
pageOffset = options?.pagination?.offset ?? 0;
|
pageOffset = options?.pagination?.offset ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3268,7 +3268,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
pagination:
|
pagination:
|
||||||
tab.mode === "data"
|
tab.mode === "data"
|
||||||
? {
|
? {
|
||||||
limit: tab.resultPageLimit ?? tableOpenPageLimit(useSettingsStore().editorSettings.pageSize),
|
limit: tab.resultPageLimit ?? tableOpenPageLimit(),
|
||||||
offset: tab.resultPageOffset ?? 0,
|
offset: tab.resultPageOffset ?? 0,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@@ -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();
|
const restoreStorage = installMemoryStorage();
|
||||||
setActivePinia(createPinia());
|
setActivePinia(createPinia());
|
||||||
const connectionStore = useConnectionStore();
|
const connectionStore = useConnectionStore();
|
||||||
@@ -2445,12 +2445,12 @@ test("data tab default pagination follows persisted rows-per-page", async () =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
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(preparedPagination, false);
|
||||||
assert.equal(executeBody.maxRows, 1000);
|
assert.equal(executeBody.maxRows, 100);
|
||||||
assert.equal(executeBody.fetchSize, 1000);
|
assert.equal(executeBody.fetchSize, 100);
|
||||||
assert.equal(tab.resultPageLimit, 1000);
|
assert.equal(tab.resultPageLimit, 100);
|
||||||
assert.equal(tab.resultPageOffset, 0);
|
assert.equal(tab.resultPageOffset, 0);
|
||||||
} finally {
|
} finally {
|
||||||
globalThis.fetch = originalFetch;
|
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 () => {
|
test("activating an empty data tab waits for explicit execution", async () => {
|
||||||
const restoreStorage = installMemoryStorage();
|
const restoreStorage = installMemoryStorage();
|
||||||
setActivePinia(createPinia());
|
setActivePinia(createPinia());
|
||||||
|
|||||||
@@ -48,10 +48,8 @@ test("normalizes saved query result page size", () => {
|
|||||||
assert.equal(normalizeEditorSettings({ pageSize: 0 }).pageSize, 100);
|
assert.equal(normalizeEditorSettings({ pageSize: 0 }).pageSize, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("uses saved rows-per-page for table opens", () => {
|
test("uses dedicated default row limit for table opens", () => {
|
||||||
assert.equal(tableOpenPageLimit(), 100);
|
assert.equal(tableOpenPageLimit(), 100);
|
||||||
assert.equal(tableOpenPageLimit(500), 500);
|
|
||||||
assert.equal(tableOpenPageLimit(0), 100);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("defaults export batch size to 2000 rows", () => {
|
test("defaults export batch size to 2000 rows", () => {
|
||||||
|
|||||||
Reference in new issue
Block a user