Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(sql-editor): display postgresError (#13767)
Liu Ji9f43dd4f0317
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/ErrorView.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/ErrorView.vueindex b362fbf627..9f6f98244c 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/ErrorView.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/ErrorView.vue@@ -19,9 +19,10 @@<span>{{ error }}</span></div></template>- <div>+ <div v-if="$slots.suffix"><slot name="suffix" /></div>+ <PostgresError v-if="resultSet" :result-set="resultSet" /><div v-if="showRunAnywayButton"><NButton size="small" type="primary" @click="runAnyway">{{ $t("sql-editor.run-anyway") }}@@ -34,13 +35,15 @@import { CircleAlertIcon } from "lucide-vue-next";import { NButton } from "naive-ui";import { Status } from "nice-grpc-common";+import { storeToRefs } from "pinia";import { computed } from "vue";import { useExecuteSQL } from "@/composables/useExecuteSQL";-import { useAppFeature } from "@/store";+import { useAppFeature, useSQLEditorTabStore } from "@/store";import type { SQLEditorQueryParams, SQLResultSetV1 } from "@/types";import { Advice_Status } from "@/types/proto/v1/sql_service";import { useSQLResultViewContext } from "../context";import AdviceItem from "./AdviceItem.vue";+import PostgresError from "./PostgresError.vue";const props = defineProps<{error: string | undefined;@@ -49,10 +52,13 @@ const props = defineProps<{}>();const sqlCheckStyle = useAppFeature("bb.feature.sql-editor.sql-check-style");+const { currentTab: tab } = storeToRefs(useSQLEditorTabStore());const { dark } = useSQLResultViewContext();const { execute } = useExecuteSQL();const showRunAnywayButton = computed(() => {+ if (!tab.value) return false;+ if (tab.value?.mode === "ADMIN") return false;const { executeParams, resultSet } = props;if (!resultSet) return false;if (!executeParams) return false;diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/PostgresError.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/PostgresError.vuenew file mode 100644index 0000000000..fd238a5505--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/PostgresError.vue@@ -0,0 +1,36 @@+<template>+ <div v-for="(error, i) in postgresErrors" :key="i" class="text-sm grid gap-1 pl-8" style="grid-template-columns: auto 1fr;">+ <template v-if="error.detail">+ <div>DETAIL:</div>+ <div>{{error.detail}}</div>+ </template>+ <template v-if="error.hint">+ <div>HINT:</div>+ <div>{{error.hint}}</div>+ </template>+ <template v-if="error.where">+ <div>WHERE:</div>+ <div>{{error.where}}</div>+ </template>+ </div>+</template>++<script setup lang="ts">+import { computed } from "vue";+import type { SQLResultSetV1 } from "@/types";+import type { QueryResult_PostgresError } from "@/types/proto/v1/sql_service";++const props = defineProps<{+ resultSet: SQLResultSetV1;+}>();++const postgresErrors = computed(() => {+ const errors: QueryResult_PostgresError[] = [];+ props.resultSet.results.forEach((result) => {+ if (result.postgresError) {+ errors.push(result.postgresError);+ }+ });+ return errors;+});+</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vueindex 7c1bb1e1dd..9caf3acd2f 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue@@ -159,7 +159,11 @@<EmptyView /></template><template v-else-if="viewMode === 'ERROR'">- <ErrorView :error="result.error" />+ <ErrorView+ :error="result.error"+ :execute-params="params"+ :result-set="sqlResultSet"+ /></template></template>