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: display statement with task's sheetId in frontend (#3962)
boojack715c05592726
diff --git a/frontend/src/components/Issue/IssueTaskStatementPanel.vue b/frontend/src/components/Issue/IssueTaskStatementPanel.vueindex 13278b54f5..ddc40c4b46 100644--- a/frontend/src/components/Issue/IssueTaskStatementPanel.vue+++ b/frontend/src/components/Issue/IssueTaskStatementPanel.vue@@ -408,6 +408,27 @@ watch(statement, (cur) => {state.editStatement = cur;});+watch(+ [selectedTask],+ async () => {+ if (isTaskHasSheetId.value) {+ const task = selectedTask.value;+ const sheetId = create.value+ ? (task as TaskCreate).sheetId+ : sheetIdOfTask(task as Task);+ if (sheetId) {+ state.editStatement = (+ await sheetStore.getOrFetchSheetById(sheetId)+ ).statement;+ }+ }+ },+ {+ immediate: true,+ deep: true,+ }+);+const beginEdit = () => {state.editStatement = statement.value;state.editing = true;@@ -514,10 +535,12 @@ const handleUploadLocalFile = async (event: Event) => {// nothing to do},onPositiveClick: () => {+ updateSheetId(undefined);updateStatement(statement);},});} else {+ updateSheetId(undefined);updateStatement(statement);}};@@ -544,7 +567,6 @@ const handleUploadLocalFileAsSheet = async (event: Event) => {});updateSheetId(sheet.id);- updateStatement(sheet.statement);state.isUploadingFile = false;if (selectedTask.value) updateEditorHeight();};diff --git a/frontend/src/components/Issue/logic/GhostModeProvider.ts b/frontend/src/components/Issue/logic/GhostModeProvider.tsindex de03866af1..c6643ac8f0 100644--- a/frontend/src/components/Issue/logic/GhostModeProvider.ts+++ b/frontend/src/components/Issue/logic/GhostModeProvider.ts@@ -1,5 +1,5 @@import { computed, defineComponent } from "vue";-import { cloneDeep } from "lodash-es";+import { cloneDeep, isUndefined } from "lodash-es";import { provideIssueLogic, useIssueLogic } from "./index";import {flattenTaskList,@@ -152,7 +152,7 @@ export default defineComponent({}};- const updateSheetId = (sheetId: SheetId) => {+ const updateSheetId = (sheetId: SheetId | undefined) => {if (!create.value) {return;}@@ -186,7 +186,12 @@ export default defineComponent({const context = issueCreate.createContext as MigrationContext;context.detailList.forEach((detail) => {const db = databaseStore.getDatabaseById(detail.databaseId!);- detail.statement = maybeFormatStatementOnSave(detail.statement, db);+ if (!isUndefined(detail.sheetId)) {+ // If task already has sheet id, we do not need to save statement.+ detail.statement = "";+ } else {+ detail.statement = maybeFormatStatementOnSave(detail.statement, db);+ }});} else {// for standard pipeline, we copy user edited tasks back to@@ -206,7 +211,12 @@ export default defineComponent({);if (detail) {const db = databaseStore.getDatabaseById(databaseId);- detail.statement = maybeFormatStatementOnSave(task.statement, db);+ if (!isUndefined(detail.sheetId)) {+ // If task already has sheet id, we do not need to save statement.+ detail.statement = "";+ } else {+ detail.statement = maybeFormatStatementOnSave(task.statement, db);+ }detail.earliestAllowedTs = task.earliestAllowedTs;}});diff --git a/frontend/src/components/Issue/logic/IssueLogic.ts b/frontend/src/components/Issue/logic/IssueLogic.tsindex 9b5cdd5940..f302d83c14 100644--- a/frontend/src/components/Issue/logic/IssueLogic.ts+++ b/frontend/src/components/Issue/logic/IssueLogic.ts@@ -62,7 +62,7 @@ type IssueLogic = {newStatement: string,postUpdated?: (updatedTask: Task) => void) => any;- updateSheetId: (sheetId: SheetId) => void;+ updateSheetId: (sheetId: SheetId | undefined) => void;allowApplyStatementToOtherTasks: Ref<boolean>;applyStatementToOtherTasks: (statement: string) => any;doCreate(): any;diff --git a/frontend/src/components/Issue/logic/TenantModeProvider.ts b/frontend/src/components/Issue/logic/TenantModeProvider.tsindex d9881579a0..0510a39d06 100644--- a/frontend/src/components/Issue/logic/TenantModeProvider.ts+++ b/frontend/src/components/Issue/logic/TenantModeProvider.ts@@ -1,5 +1,5 @@import { computed, defineComponent } from "vue";-import { cloneDeep } from "lodash-es";+import { cloneDeep, isUndefined } from "lodash-es";import { useDatabaseStore, useTaskStore } from "@/store";import {Issue,@@ -84,7 +84,7 @@ export default defineComponent({}};- const updateSheetId = (sheetId: SheetId) => {+ const updateSheetId = (sheetId: SheetId | undefined) => {if (!create.value) {return;}@@ -113,7 +113,12 @@ export default defineComponent({const context = issueCreate.createContext as MigrationContext;context.detailList.forEach((detail) => {const db = databaseStore.getDatabaseById(detail.databaseId!);- detail.statement = maybeFormatStatementOnSave(detail.statement, db);+ if (!isUndefined(detail.sheetId)) {+ // If task already has sheet id, we do not need to save statement.+ detail.statement = "";+ } else {+ detail.statement = maybeFormatStatementOnSave(detail.statement, db);+ }});createIssue(issueCreate);diff --git a/frontend/src/components/Issue/logic/common.ts b/frontend/src/components/Issue/logic/common.tsindex aa95de4e8b..ef6c2fc3b0 100644--- a/frontend/src/components/Issue/logic/common.ts+++ b/frontend/src/components/Issue/logic/common.ts@@ -1,5 +1,5 @@import { computed } from "vue";-import { cloneDeep } from "lodash-es";+import { cloneDeep, isUndefined } from "lodash-es";import { useRoute } from "vue-router";import formatSQL from "@/components/MonacoEditor/sqlFormatter";import {@@ -181,7 +181,7 @@ export const useCommonLogic = () => {}};- const updateSheetId = (sheetId: SheetId) => {+ const updateSheetId = (sheetId: SheetId | undefined) => {if (!create.value) {return;}@@ -204,6 +204,10 @@ export const useCommonLogic = () => {sheetId: taskCreate.sheetId,earliestAllowedTs: taskCreate.earliestAllowedTs,};+ // If task already has sheet id, we do not need to save statement.+ if (!isUndefined(taskCreate.sheetId)) {+ migrationDetail.statement = "";+ }return migrationDetail;});diff --git a/server/issue.go b/server/issue.goindex aa5c90713d..79613edade 100644--- a/server/issue.go+++ b/server/issue.go@@ -754,6 +754,9 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Conif detail.MigrationType != db.Baseline && (detail.Statement == "" && detail.SheetID == 0) {return nil, echo.NewHTTPError(http.StatusBadRequest, "require sql statement or sheet ID to create an issue")}+ if detail.Statement != "" && detail.SheetID > 0 {+ return nil, echo.NewHTTPError(http.StatusBadRequest, "Cannot set both statement and sheet ID to create an issue")+ }// TODO(d): validate sheet ID.if detail.DatabaseID > 0 {databaseIDCount++diff --git a/server/runner/backuprun/runner.go b/server/runner/backuprun/runner.goindex 312f455e25..f088d937bc 100644--- a/server/runner/backuprun/runner.go+++ b/server/runner/backuprun/runner.go@@ -330,7 +330,6 @@ func (r *Runner) startAutoBackups(ctx context.Context) {continue}if len(backupList) > 0 {- log.Debug("Skip creating backup because it already exists", zap.Int("database-id", db.ID), zap.String("name", backupName))continue}