25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(data): decouple table open limit from result page size
t8y274165cc04525
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vueindex c59c9da898..d62d630555 100644--- a/apps/desktop/src/components/sidebar/TreeItem.vue+++ b/apps/desktop/src/components/sidebar/TreeItem.vue@@ -74,6 +74,7 @@ import { connectionFilePath, defaultSqliteBackupFileName, isMemorySqlitePath, sqimport { revealPathInFileManager } from "@/lib/tauri";import { clearActiveTableReferencePayload, createTableReferencePayload, createTableReferenceDropEvent, setActiveTableReferencePayload, type QueryEditorTableReferencePayload } from "@/lib/queryEditorTableDrop";import { editableRowIdentifierColumns, usesSyntheticRowIdKey } from "@/lib/tableEditing";+import { tableOpenPageLimit } from "@/lib/tableOpenPageLimit";import { supportsDatabaseCreation, supportsDatabaseSearch, supportsFieldLineage, supportsObjectBrowserTreeNode, supportsSchemaDiagram, supportsSqlFileExecution, supportsTableImport, supportsTableTruncate, supportsTableStructureEditing, usesTreeSchemaMode } from "@/lib/databaseCapabilities";import { copyNameForTreeNode, objectSourceKindForTreeNode, sidebarSelectionCopyAction, treeNodeRowAction, treeNodeRowDoubleClickAction } from "@/lib/treeNodeClick";import { formatSqlInsert } from "@/lib/exportFormats";@@ -1047,7 +1048,7 @@ async function openData() {const querySchema = connectionObjectTreeQuerySchema(config, node.database, tableSchema);const effectiveDbType = effectiveDatabaseTypeForConnection(config);- const limit = settingsStore.editorSettings.pageSize;+ const limit = tableOpenPageLimit();const refreshTableMetaInBackground = async () => {const metadataStartedAt = performance.now();console.info("[DBX][openData:metadata:start]", {@@ -1134,7 +1135,11 @@ async function openData() {logPhase("sql-updated", { tabId });console.info("[DBX][openData:execute:start]", { traceId, tabId, elapsed: elapsed() });- await queryStore.executeTabSql(tabId, sql, { sourceTraceId: traceId, skipEnsureConnected: true });+ await queryStore.executeTabSql(tabId, sql, {+ sourceTraceId: traceId,+ skipEnsureConnected: true,+ pagination: { limit, offset: 0 },+ });console.info("[DBX][openData:execute:done]", { traceId, tabId, elapsed: elapsed() });logPhase("execute-tab-sql", { tabId });if (shouldRefreshTableMeta && isCurrentDataTab()) {diff --git a/apps/desktop/src/composables/useNavigationTargets.ts b/apps/desktop/src/composables/useNavigationTargets.tsindex df9e8aed72..055e80cf87 100644--- a/apps/desktop/src/composables/useNavigationTargets.ts+++ b/apps/desktop/src/composables/useNavigationTargets.ts@@ -3,6 +3,7 @@ import { effectiveDatabaseTypeForConnection, metadataSchemaForConnection } fromimport { isNoSnapshotErrorResult } from "@/lib/queryResultError";import { buildTableSelectSql } from "@/lib/tableSelectSql";import { editableRowIdentifierColumns, usesSyntheticRowIdKey } from "@/lib/tableEditing";+import { tableOpenPageLimit } from "@/lib/tableOpenPageLimit";import { useConnectionStore } from "@/stores/connectionStore";import { useQueryStore } from "@/stores/queryStore";import { useSettingsStore } from "@/stores/settingsStore";@@ -21,7 +22,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTabconst connectionStore = useConnectionStore();const queryStore = useQueryStore();const settingsStore = useSettingsStore();- const pageLimit = settingsStore.editorSettings.pageSize;+ const pageLimit = tableOpenPageLimit();connectionStore.activeConnectionId = target.connectionId;const config = connectionStore.getConfig(target.connectionId);@@ -74,7 +75,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTabcolumns,primaryKeys,});- await queryStore.executeTabSql(tabId, sql);+ await queryStore.executeTabSql(tabId, sql, { pagination: { limit: pageLimit, offset: 0 } });return;}const sql = await buildTableSelectSql({@@ -92,7 +93,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTabcolumns: [],primaryKeys: [],});- await queryStore.executeTabSql(tabId, sql);+ await queryStore.executeTabSql(tabId, sql, { pagination: { limit: pageLimit, offset: 0 } });// executeTabSql surfaces query failures as an "Error" result instead of throwing.// A snapshot-less lake table fails the data preview above but its metadata still// reads fine — retry with LIMIT 0 so the user sees the table structure (columns +@@ -109,7 +110,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTablimit: 0,});queryStore.updateSql(tabId, emptySql);- await queryStore.executeTabSql(tabId, emptySql);+ await queryStore.executeTabSql(tabId, emptySql, { pagination: { limit: pageLimit, offset: 0 } });}try {const columns = await api.getColumns(target.connectionId, target.database, querySchema, target.tableName);@@ -135,7 +136,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTablimit: pageLimit,});queryStore.updateSql(tabId, newSql);- await queryStore.executeTabSql(tabId, newSql);+ await queryStore.executeTabSql(tabId, newSql, { pagination: { limit: pageLimit, offset: 0 } });}} catch (reason) {console.error("[DBX] ERROR fetching table metadata:", reason);diff --git a/apps/desktop/src/lib/tableOpenPageLimit.ts b/apps/desktop/src/lib/tableOpenPageLimit.tsnew file mode 100644index 0000000000..2b2fc56d11--- /dev/null+++ b/apps/desktop/src/lib/tableOpenPageLimit.ts@@ -0,0 +1,8 @@+import { DEFAULT_RESULT_PAGE_SIZE, normalizeResultPageSize } from "@/lib/paginationPageSize";++export const DEFAULT_TABLE_OPEN_PAGE_LIMIT = DEFAULT_RESULT_PAGE_SIZE;++export function tableOpenPageLimit(): number {+ // Opening a table should not inherit the mutable SQL result-grid rows-per-page setting.+ return normalizeResultPageSize(DEFAULT_TABLE_OPEN_PAGE_LIMIT);+}diff --git a/apps/desktop/src/stores/queryStore.ts b/apps/desktop/src/stores/queryStore.tsindex 86bbc9b876..c867fc1b3c 100644--- a/apps/desktop/src/stores/queryStore.ts+++ b/apps/desktop/src/stores/queryStore.ts@@ -34,6 +34,7 @@ import { usesAgentCursorForQuery } from "@/lib/databaseDriverManifest";import { canUseKeylessRowPredicate, editableRowIdentifierColumns } from "@/lib/tableEditing";import { TABLE_DATA_EXPORT_PAGE_SIZE } from "@/lib/tableDataExport";import { tableMetaForDataTab } from "@/lib/tableDataTabMeta";+import { tableOpenPageLimit } from "@/lib/tableOpenPageLimit";import { quoteTableIdentifier } from "@/lib/tableSelectSql";import { connectionUsesDatabaseObjectTreeMode, connectionUsesSchemaExecutionContext, effectiveDatabaseTypeForConnection, metadataSchemaForConnection } from "@/lib/jdbcDialect";import { queryTimeoutSecsForConnection } from "@/lib/queryTimeout";@@ -1607,7 +1608,7 @@ export const useQueryStore = defineStore("query", () => {countSql = plan.countSql;useAgentResultSession = plan.useAgentResultSession;} else if (tab.mode === "data") {- pageLimit = options?.pagination?.limit ?? settingsStore.editorSettings.pageSize;+ pageLimit = options?.pagination?.limit ?? tableOpenPageLimit();pageOffset = options?.pagination?.offset ?? 0;}const mongoFind = conn?.db_type === "mongodb" ? parseMongoFindCommand(sql) : null;@@ -2276,14 +2277,13 @@ export const useQueryStore = defineStore("query", () => {tab.resultEvicted = false;const sql = tab.lastExecutedSql ?? tab.sql;if (!sql?.trim()) return;- const settingsStore = useSettingsStore();await executeTabSql(tab.id, sql, {resultBaseSql: tab.resultBaseSql ?? sql,resultSortedSql: tab.resultSortedSql,pagination:tab.mode === "data"? {- limit: tab.resultPageLimit ?? settingsStore.editorSettings.pageSize,+ limit: tab.resultPageLimit ?? tableOpenPageLimit(),offset: tab.resultPageOffset ?? 0,}: undefined,diff --git a/packages/app-tests/queryStore.test.ts b/packages/app-tests/queryStore.test.tsindex dac8c742d3..351d4a0255 100644--- a/packages/app-tests/queryStore.test.ts+++ b/packages/app-tests/queryStore.test.ts@@ -1527,6 +1527,52 @@ test("data tab execution preserves pagination offset metadata", async () => {}});+test("data tab default pagination is independent from query result page size", async () => {+ const restoreStorage = installMemoryStorage();+ setActivePinia(createPinia());+ const connectionStore = useConnectionStore();+ const settingsStore = useSettingsStore();+ const store = useQueryStore();+ const originalFetch = globalThis.fetch;+ let executeBody: any;+ let preparedPagination = false;++ 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);++ globalThis.fetch = withConnectionHealthMock(async (input, init) => {+ const url = String(input);+ if (url === "/api/query/prepare-pagination-plan") {+ preparedPagination = true;+ return new Response("unexpected pagination plan request", { status: 500 });+ }+ if (url === "/api/query/execute-multi") {+ executeBody = JSON.parse(String(init?.body ?? "{}"));+ return new Response(JSON.stringify([{ columns: ["id"], rows: [[1]], affected_rows: 0, execution_time_ms: 1 }]), {+ status: 200,+ headers: { "Content-Type": "application/json" },+ });+ }+ return new Response("unexpected request", { status: 500 });+ });++ try {+ await store.executeTabSql(tabId, 'SELECT * FROM "users" LIMIT 100;');++ assert.equal(preparedPagination, false);+ assert.equal(executeBody.maxRows, 100);+ assert.equal(executeBody.fetchSize, 100);+ assert.equal(tab.resultPageLimit, 100);+ assert.equal(tab.resultPageOffset, 0);+ } finally {+ globalThis.fetch = originalFetch;+ restoreStorage();+ }+});+test("activating an empty data tab waits for explicit execution", async () => {const restoreStorage = installMemoryStorage();setActivePinia(createPinia());