Skip to content

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

chore: improve robustness when uploading sql files (#7450)

Liu Ji66716c639a5a
diff --git a/frontend/src/components/Issue/IssueTaskStatementPanel.vue b/frontend/src/components/Issue/IssueTaskStatementPanel.vue
index 3771d13c13..ff34a20e83 100644
--- a/frontend/src/components/Issue/IssueTaskStatementPanel.vue
+++ b/frontend/src/components/Issue/IssueTaskStatementPanel.vue
@@ -48,7 +48,10 @@
{{ $t("issue.format-on-save") }}
</NCheckbox>
- <UploadProgressButton :upload="handleUploadFile" size="tiny">
+ <UploadProgressButton
+ :upload="create ? handleUploadFile : handleUploadAndOverwrite"
+ size="tiny"
+ >
{{ $t("issue.upload-sql") }}
</UploadProgressButton>
</template>
@@ -534,6 +537,7 @@ const handleUploadAndOverwrite = async (event: Event) => {
});
} finally {
state.isUploadingFile = false;
+ state.editing = false;
}
};
diff --git a/frontend/src/components/Issue/activity/ActionSentence.vue b/frontend/src/components/Issue/activity/ActionSentence.vue
index 6b515e4fb6..e9da46ed13 100644
--- a/frontend/src/components/Issue/activity/ActionSentence.vue
+++ b/frontend/src/components/Issue/activity/ActionSentence.vue
@@ -16,6 +16,7 @@ import {
ActivityTaskStatusUpdatePayload,
Issue,
SYSTEM_BOT_EMAIL,
+ UNKNOWN_ID,
empty,
} from "@/types";
import {
@@ -211,11 +212,11 @@ const renderActionSentence = () => {
activity.payload
) as ActivityTaskStatementUpdatePayload;
const oldStatement =
- useSheetStatementByUID(String(payload.oldSheetId)).value ||
- payload.oldStatement;
+ useSheetStatementByUID(String(payload.oldSheetId || UNKNOWN_ID))
+ .value || payload.oldStatement;
const newStatement =
- useSheetStatementByUID(String(payload.newSheetId)).value ||
- payload.newStatement;
+ useSheetStatementByUID(String(payload.newSheetId || UNKNOWN_ID))
+ .value || payload.newStatement;
return h(
"span",
{},
@@ -308,13 +309,13 @@ watch(
sheetV1Store.getOrFetchSheetByUID(
String(
(JSON.parse(activity.payload) as ActivityTaskStatementUpdatePayload)
- .newSheetId
+ .newSheetId || UNKNOWN_ID
)
);
sheetV1Store.getOrFetchSheetByUID(
String(
(JSON.parse(activity.payload) as ActivityTaskStatementUpdatePayload)
- .oldSheetId
+ .oldSheetId || UNKNOWN_ID
)
);
}
diff --git a/frontend/src/store/modules/v1/sheet.ts b/frontend/src/store/modules/v1/sheet.ts
index a4e0185554..563776b6ff 100644
--- a/frontend/src/store/modules/v1/sheet.ts
+++ b/frontend/src/store/modules/v1/sheet.ts
@@ -77,6 +77,10 @@ export const useSheetV1Store = defineStore("sheet_v1", () => {
return sheetsByName.value.get(name);
};
const fetchSheetByName = async (name: string) => {
+ const uid = extractSheetUID(name);
+ if (uid.startsWith("-") || !uid) {
+ return undefined;
+ }
try {
const sheet = await sheetServiceClient.getSheet({
name,
@@ -89,6 +93,9 @@ export const useSheetV1Store = defineStore("sheet_v1", () => {
};
const getOrFetchSheetByName = async (name: string) => {
const uid = extractSheetUID(name);
+ if (uid.startsWith("-") || !uid) {
+ return undefined;
+ }
if (uid === String(UNKNOWN_ID)) {
return undefined;
}
@@ -120,6 +127,9 @@ export const useSheetV1Store = defineStore("sheet_v1", () => {
}
};
const fetchSheetByUID = async (uid: string, raw = false) => {
+ if (uid.startsWith("-") || !uid) {
+ return undefined;
+ }
try {
const name = `projects/-/sheets/${uid}`;
const sheet = await sheetServiceClient.getSheet({
@@ -133,6 +143,9 @@ export const useSheetV1Store = defineStore("sheet_v1", () => {
}
};
const getOrFetchSheetByUID = async (uid: string) => {
+ if (uid.startsWith("-") || !uid) {
+ return undefined;
+ }
if (uid === String(UNKNOWN_ID)) {
return undefined;
}