Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(sql-editor): Incorrect export index with multiple result tabs (#10591)

Liu Ji44b1d6f12f21
diff --git a/frontend/src/components/DataExportButton.vue b/frontend/src/components/DataExportButton.vue
index daf33cf7a8..e9b4766479 100644
--- a/frontend/src/components/DataExportButton.vue
+++ b/frontend/src/components/DataExportButton.vue
@@ -92,7 +92,7 @@
<div class="w-80">
<span class="textinfolabel">{{ $t("export-data.password-info") }}</span>
<BBTextField
- v-modal:value="formData.password"
+ v-model:value="formData.password"
class="my-2"
:focus-on-mount="true"
/>
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
index 76ded22af3..b532737be2 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
@@ -8,6 +8,7 @@
<template v-if="viewMode === 'SINGLE-RESULT'">
<SingleResultViewV1
:params="executeParams"
+ :database="database"
:sql-result-set="resultSet"
:result="resultSet.results[0]"
:set-index="0"
@@ -90,7 +91,12 @@ import {
usePolicyV1Store,
useTabStore,
} from "@/store";
-import { ExecuteConfig, ExecuteOption, SQLResultSetV1 } from "@/types";
+import {
+ ComposedDatabase,
+ ExecuteConfig,
+ ExecuteOption,
+ SQLResultSetV1,
+} from "@/types";
import { PolicyType } from "@/types/proto/v1/org_policy_service";
import { QueryResult } from "@/types/proto/v1/sql_service";
import { hasWorkspacePermissionV2 } from "@/utils";
@@ -115,6 +121,10 @@ const props = defineProps({
}>,
default: undefined,
},
+ database: {
+ type: Object as PropType<ComposedDatabase>,
+ default: undefined,
+ },
resultSet: {
type: Object as PropType<SQLResultSetV1>,
default: undefined,
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
index 234be90321..6a2a7720b9 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
@@ -176,6 +176,7 @@ import {
} from "@/store";
import { useExportData } from "@/store/modules/export";
import {
+ ComposedDatabase,
ExecuteConfig,
ExecuteOption,
SQLResultSetV1,
@@ -215,6 +216,7 @@ const props = defineProps<{
config: ExecuteConfig;
option?: Partial<ExecuteOption> | undefined;
};
+ database?: ComposedDatabase;
sqlResultSet: SQLResultSetV1;
result: QueryResult;
setIndex: number;
@@ -363,12 +365,20 @@ const handleExportBtnClick = async (
options: ExportOption,
callback: (content: BinaryLike | Blob, options: ExportOption) => void
) => {
- const { instanceId, databaseId } = tabStore.currentTab.connection;
- const instance = instanceStore.getInstanceByUID(instanceId).name;
+ // If props.database is specified and it's not unknown database
+ // the query is executed on database level
+ // otherwise the query is executed on instance level, we should use the
+ // `instanceId` from the tab's connection attributes
const database =
- databaseId === String(UNKNOWN_ID)
- ? ""
- : databaseStore.getDatabaseByUID(databaseId).name;
+ props.database && props.database.uid !== String(UNKNOWN_ID)
+ ? props.database.name
+ : "";
+ const instance =
+ props.database && props.database.uid !== String(UNKNOWN_ID)
+ ? props.database.instance
+ : instanceStore.getInstanceByUID(
+ tabStore.currentTab.connection.instanceId
+ ).name;
const statement = props.result.statement;
const admin = tabStore.currentTab.mode === TabMode.Admin;
const limit = options.limit ?? (admin ? 0 : RESULT_ROWS_LIMIT);
diff --git a/frontend/src/views/sql-editor/ResultPanel/ResultPanel.vue b/frontend/src/views/sql-editor/ResultPanel/ResultPanel.vue
index 130044a8c9..f512d747ea 100644
--- a/frontend/src/views/sql-editor/ResultPanel/ResultPanel.vue
+++ b/frontend/src/views/sql-editor/ResultPanel/ResultPanel.vue
@@ -70,6 +70,7 @@
v-else
class="w-full h-auto grow"
:execute-params="executeParams"
+ :database="selectedDatabase"
:result-set="selectedResultSet"
/>
</template>