Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: use sheetId in rollback issue creation (#5912)
boojacka433103a6411
diff --git a/frontend/src/components/Issue/IssueDetailLayout.vue b/frontend/src/components/Issue/IssueDetailLayout.vueindex 890eb6a5a8..9581c60f7b 100644--- a/frontend/src/components/Issue/IssueDetailLayout.vue+++ b/frontend/src/components/Issue/IssueDetailLayout.vue@@ -318,15 +318,14 @@ watch(],([create, issue, sqlList, sql, provider]) => {if (create && issue && provider) {- if (sqlList) {- // If 'sqlList' in URL query, initial the tasks's statement in issueCreate from current route.- // TODO: Maybe we should save database id list and sql list into session state to prevent url too long.- provider.initialTaskListStatementFromRoute();- } else if (sql) {+ if (sql) {// If 'sql' in URL query, update the issueCreate's statement// Only works for the first time.// E.g. redirected from SQL editor when user wants to execute DML.provider.updateStatement(sql);+ } else {+ // Initial the tasks's statement/sheetId in issueCreate from current route.+ provider.initialTaskListStatementFromRoute();}}}diff --git a/frontend/src/components/Issue/logic/common.ts b/frontend/src/components/Issue/logic/common.tsindex 93f78c5926..0f459fb08c 100644--- a/frontend/src/components/Issue/logic/common.ts+++ b/frontend/src/components/Issue/logic/common.ts@@ -24,7 +24,6 @@ import {TaskType,MigrationDetail,MigrationType,- DatabaseId,SheetId,MigrationContext,dialectOfEngine,@@ -100,28 +99,40 @@ export const useCommonLogic = () => {const taskList = flattenTaskList<TaskCreate>(issue.value).filter((task) =>TaskTypeWithStatement.includes(task.type));- const databaseStatementMap = new Map<DatabaseId, string>();// route.query.databaseList is comma-splitted databaseId list// e.g. databaseList=7002,7006,7014const idListString = route.query.databaseList as string;+ const databaseIdList = idListString.split(",");+ if (databaseIdList.length === 0) {+ return;+ }++ // route.query.sheetIdString is sheetId. Mainly using in creating rollback issue.+ const sheetIdString = route.query.sheetId as string;// route.query.sqlList is JSON string of a string array.const sqlListString = route.query.sqlList as string;- if (idListString && sqlListString) {- const databaseIdList = idListString.split(",");+ if (sheetIdString) {+ for (const databaseId of databaseIdList) {+ const task = taskList.find(+ (task) => task.databaseId === Number(databaseId)+ );+ if (task) {+ task.sheetId = sheetIdString;+ }+ }+ } else if (idListString && sqlListString) {const statementList = JSON.parse(sqlListString) as string[];for (let i = 0;i < Math.min(databaseIdList.length, statementList.length);i++) {- databaseStatementMap.set(Number(databaseIdList[i]), statementList[i]);- }- }-- for (const [databaseId, statement] of databaseStatementMap) {- const task = taskList.find((task) => task.databaseId === databaseId);- if (task) {- task.statement = statement;+ const task = taskList.find(+ (task) => task.databaseId === databaseIdList[i]+ );+ if (task) {+ task.statement = statementList[i];+ }}}};diff --git a/frontend/src/components/Issue/rollback/RollbackStatus.vue b/frontend/src/components/Issue/rollback/RollbackStatus.vueindex d76e38cfc3..65868dafae 100644--- a/frontend/src/components/Issue/rollback/RollbackStatus.vue+++ b/frontend/src/components/Issue/rollback/RollbackStatus.vue@@ -81,7 +81,7 @@ import { useRollbackLogic } from "./common";import IssueStatusIcon from "../IssueStatusIcon.vue";import LogButton from "./LogButton.vue";import LoggingButton from "./LoggingButton.vue";-import { useActivityStore, useIssueById } from "@/store";+import { useActivityStore, useIssueById, useSheetStore } from "@/store";import LearnMoreLink from "@/components/LearnMoreLink.vue";type LocalState = {@@ -90,6 +90,7 @@ type LocalState = {};const router = useRouter();+const sheetStore = useSheetStore();const context = useIssueLogic();const { allowRollback } = useRollbackLogic();@@ -157,10 +158,12 @@ const tryRollbackTask = async () => {`${issue.value.name}`,].join(" ");- // TODO(boojack): use sheetID. Or can we display partial sheet or link the sheet here.+ const rollbackSheet = await sheetStore.getOrFetchSheetById(+ payload.value!.rollbackSheetId!+ );const description = ["The original SQL statement:",- `${payload.value!.statement}`,+ `${rollbackSheet.statement}`,].join("\n");router.push({@@ -175,8 +178,7 @@ const tryRollbackTask = async () => {databaseList: [task.value.database!.id].join(","),rollbackIssueId: issue.value.id,rollbackTaskIdList: [task.value.id].join(","),- // TODO(boojack): use the rollbackSheetId.- sql: "",+ sheetId: rollbackSheet.id,description,},});