diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue index 09dbb66cd9..055fecac9f 100644 --- a/src/components/grid/DataGrid.vue +++ b/src/components/grid/DataGrid.vue @@ -80,6 +80,7 @@ const props = defineProps<{ connectionId?: string; database?: string; context?: "results" | "table-data"; + initialWhereInput?: string; tableMeta?: { schema?: string; tableName: string; @@ -228,7 +229,7 @@ const orderBySuggestionLeft = ref(0); const orderByInput = ref(""); const hasOrderByInput = computed(() => orderByInput.value.trim().length > 0); -const whereFilterInput = ref(""); +const whereFilterInput = ref(props.initialWhereInput ?? ""); const hasWhereFilterInput = computed(() => whereFilterInput.value.trim().length > 0); type LocalColumnFilterDraft = { diff --git a/src/components/layout/ContentArea.vue b/src/components/layout/ContentArea.vue index 282fc0c36a..670c00b9e3 100644 --- a/src/components/layout/ContentArea.vue +++ b/src/components/layout/ContentArea.vue @@ -374,6 +374,7 @@ function onHandleCloseColumnPanel() { :loading="activeTab.isExecuting" :editable="!!activeTab.tableMeta?.primaryKeys?.length" context="table-data" + :initial-where-input="activeTab.whereInput" :database-type="activeConnection?.db_type" :connection-id="activeTab.connectionId" :database="activeTab.database" diff --git a/src/composables/useDataGridActions.ts b/src/composables/useDataGridActions.ts index 813beaa552..175f52e5de 100644 --- a/src/composables/useDataGridActions.ts +++ b/src/composables/useDataGridActions.ts @@ -48,6 +48,7 @@ export function useDataGridActions(activeTab: ComputedRef) const tab = activeTab.value; if (!tab) return; if (tab.mode === "data" && tab.tableMeta) { + tab.whereInput = whereInput ?? ""; queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput, orderBy })); await queryStore.executeCurrentTab(); return; @@ -72,6 +73,7 @@ export function useDataGridActions(activeTab: ComputedRef) async function onPaginate(offset: number, limit: number, whereInput?: string, orderBy?: string) { const tab = activeTab.value; if (!tab?.tableMeta) return; + tab.whereInput = whereInput ?? ""; const sql = buildTableSql(tab, { limit, offset, whereInput, orderBy }); queryStore.updateSql(tab.id, sql); await queryStore.executeCurrentTab(); @@ -83,6 +85,7 @@ export function useDataGridActions(activeTab: ComputedRef) if (tab.mode === "data") { if (!tab.tableMeta) return; + tab.whereInput = whereInput ?? ""; const orderBy = direction ? `${quoteIdent(tab, column)} ${direction.toUpperCase()}` : undefined; const sql = buildTableSql(tab, { orderBy, whereInput }); queryStore.updateSql(tab.id, sql); diff --git a/src/types/database.ts b/src/types/database.ts index 63b7892062..dca1fd7bc1 100644 --- a/src/types/database.ts +++ b/src/types/database.ts @@ -251,6 +251,7 @@ export interface QueryTab { selectStar: boolean; columns: string[]; }; + whereInput?: string; } export interface SavedSqlFolder {