Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: remove view definition from sql review result (#15587)
boojackff305479f807
diff --git a/backend/plugin/advisor/sql_review.go b/backend/plugin/advisor/sql_review.goindex cd3838b266..5c69b61133 100644--- a/backend/plugin/advisor/sql_review.go+++ b/backend/plugin/advisor/sql_review.go@@ -1,14 +1,12 @@package advisorimport (- "bytes""context""database/sql""encoding/json""fmt""log/slog""regexp"- "strings""github.com/pkg/errors"@@ -545,7 +543,7 @@ func SQLReviewCheck(switch checkContext.DbType {case storepb.Engine_TIDB, storepb.Engine_MYSQL, storepb.Engine_MARIADB, storepb.Engine_POSTGRES, storepb.Engine_OCEANBASE:if err := finder.WalkThrough(asts); err != nil {- return convertWalkThroughErrorToAdvice(ctx, checkContext, err)+ return convertWalkThroughErrorToAdvice(err)}}}@@ -622,7 +620,7 @@ func SQLReviewCheck(return advices, nil}-func convertWalkThroughErrorToAdvice(ctx context.Context, checkContext SQLReviewCheckContext, err error) ([]*storepb.Advice, error) {+func convertWalkThroughErrorToAdvice(err error) ([]*storepb.Advice, error) {walkThroughError, ok := err.(*catalog.WalkThroughError)if !ok {return nil, err@@ -799,18 +797,6 @@ func convertWalkThroughErrorToAdvice(ctx context.Context, checkContext SQLReview})case catalog.ErrorTypeColumnIsReferencedByView:details := walkThroughError.Content- if checkContext.DbType == storepb.Engine_POSTGRES {- list, yes := walkThroughError.Payload.([]string)- if !yes {- return nil, errors.Errorf("invalid payload for ColumnIsReferencedByView, expect []string but found %T", walkThroughError.Payload)- }- if definition, err := getViewDefinition(ctx, checkContext, list); err != nil {- slog.Warn("failed to get view definition", log.BBError(err))- } else {- details = definition- }- }-res = append(res, &storepb.Advice{Status: storepb.Advice_ERROR,Code: ColumnIsReferencedByView.Int32(),@@ -822,18 +808,6 @@ func convertWalkThroughErrorToAdvice(ctx context.Context, checkContext SQLReview})case catalog.ErrorTypeTableIsReferencedByView:details := walkThroughError.Content- if checkContext.DbType == storepb.Engine_POSTGRES {- list, yes := walkThroughError.Payload.([]string)- if !yes {- return nil, errors.Errorf("invalid payload for TableIsReferencedByView, expect []string but found %T", walkThroughError.Payload)- }- if definition, err := getViewDefinition(ctx, checkContext, list); err != nil {- slog.Warn("failed to get view definition", log.BBError(err))- } else {- details = definition- }- }-res = append(res, &storepb.Advice{Status: storepb.Advice_ERROR,Code: TableIsReferencedByView.Int32(),@@ -868,49 +842,6 @@ func convertWalkThroughErrorToAdvice(ctx context.Context, checkContext SQLReviewreturn res, nil}-func getViewDefinition(ctx context.Context, checkContext SQLReviewCheckContext, viewList []string) (string, error) {- var buf bytes.Buffer- sql := fmt.Sprintf(`- WITH view_list(view_name) AS (- VALUES ('%s')- )- SELECT view_name, pg_get_viewdef(view_name) AS view_definition- FROM view_list;- `, strings.Join(viewList, "'),('"))-- rows, err := checkContext.Driver.QueryContext(ctx, sql)- if err != nil {- return "", err- }- defer rows.Close()- for rows.Next() {- var viewName, viewDefinition string- if err := rows.Scan(&viewName, &viewDefinition); err != nil {- return "", err- }- if _, err := buf.WriteString("The definition of view "); err != nil {- return "", err- }- if _, err := buf.WriteString(viewName); err != nil {- return "", err- }- if _, err := buf.WriteString(" is \n"); err != nil {- return "", err- }- if _, err := buf.WriteString(viewDefinition); err != nil {- return "", err- }- if _, err := buf.WriteString("\n\n"); err != nil {- return "", err- }- }- if err := rows.Err(); err != nil {- return "", err- }-- return buf.String(), nil-}-func getAdvisorTypeByRule(ruleType SQLReviewRuleType, engine storepb.Engine) (Type, error) {switch ruleType {case SchemaRuleStatementRequireWhereForSelect:diff --git a/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue b/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vueindex bdf7d5fd72..52e6ebc1f9 100644--- a/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue+++ b/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue@@ -64,13 +64,6 @@<divclass="flex items-center justify-start space-x-2 divide-x divide-block-border">- <div v-if="row.checkResult.content" class="pl-2 first:pl-0">- <span- class="normal-link"- @click="state.activeResultDefinition = row.checkResult.content"- >{{ $t("sql-review.view-definition") }}</span- >- </div><divv-if="row.checkResult.sqlReviewReport &&@@ -158,14 +151,6 @@</div><div class="textinfolabel"><span>{{ row.checkResult.content }}</span>- <template v-if="row.checkResult.content">- <span- class="ml-1 normal-link"- @click="state.activeResultDefinition = row.checkResult.content"- >{{ $t("sql-review.view-definition") }}</span- >- <span class="border-r border-control-border ml-1"></span>- </template><templatev-if="row.checkResult.sqlReviewReport &&@@ -235,12 +220,6 @@:disabled="true"@cancel="state.activeRule = undefined"/>-- <PlanCheckResultDefinitionModal- v-if="state.activeResultDefinition"- :definition="state.activeResultDefinition"- @close="state.activeResultDefinition = undefined"- /></template><script setup lang="ts">@@ -273,7 +252,6 @@ import {PlanCheckRun_Result_Status,PlanCheckRun_Status,} from "@/types/proto/v1/plan_service";-import PlanCheckResultDefinitionModal from "./PlanCheckResultDefinitionModal.vue";import { usePlanCheckRunContext } from "./context";import { OnlineMigrationDetail } from "./detail";@@ -292,7 +270,6 @@ export type PlanCheckDetailTableRow = {type LocalState = {activeRule?: RuleTemplateV2;- activeResultDefinition?: string;};const props = defineProps<{@@ -307,7 +284,6 @@ const { events } = usePlanCheckRunContext();const hideDocLink = useAppFeature("bb.feature.sql-check.hide-doc-link");const state = reactive<LocalState>({activeRule: undefined,- activeResultDefinition: undefined,});const statusIconClass = (status: PlanCheckRun_Result_Status) => {