Skip to content

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

chore: disallow to create issue if generate statement failed (#14082)

ecmadao00ae17b339e8
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
index 872062484a..f09c26cd42 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
@@ -361,26 +361,19 @@ const generateOrGetEditingDDL = async () => {
return {
statement: state.editStatement,
errors: [],
+ fatal: false,
};
}
const statementMap = await generateDiffDDLMap(/* silent */ true);
const results = Array.from(statementMap.values());
const statement = results.map((result) => result.statement).join("\n\n");
- results.forEach((result) => {
- if (result.errors.length > 0) {
- pushNotification({
- module: "bytebase",
- style: result.fatal ? "CRITICAL" : "WARN",
- title: t("common.error"),
- description: result.errors.join("\n"),
- });
- }
- });
+
const errors = results.flatMap((result) => result.errors);
return {
statement,
errors,
+ fatal: results.some((result) => result.fatal),
};
};
@@ -398,7 +391,7 @@ const generateDiffDDLMap = async (silent: boolean) => {
for (let i = 0; i < state.targets.length; i++) {
const target = state.targets[i];
const { database, baselineMetadata: source, metadata } = target;
- await applyMetadataEdit(database, metadata);
+ applyMetadataEdit(database, metadata);
const result = await generateSingleDiffDDL(
database,
source,
@@ -534,7 +527,7 @@ const renderEmptyGeneratedDDLContent = (databases: ComposedDatabase[]) => {
keypath: "schema-editor.nothing-changed-for-database",
},
{
- database: database.databaseName,
+ database: () => database.databaseName,
}
);
});
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
index bd9def9c03..16294f8219 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
@@ -35,7 +35,11 @@ import { useSchemaEditorSQLCheck } from "./useSchemaEditorSQLCheck";
const props = defineProps<{
databaseList: ComposedDatabase[];
- getStatement: () => Promise<{ statement: string; errors: string[] }>;
+ getStatement: () => Promise<{
+ statement: string;
+ errors: string[];
+ fatal: boolean;
+ }>;
useOnlineSchemaMigration: boolean;
}>();
diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vue
index aaf660ddf7..75204b3d5f 100644
--- a/frontend/src/components/Branch/BranchDetailView.vue
+++ b/frontend/src/components/Branch/BranchDetailView.vue
@@ -359,7 +359,7 @@ const handleSaveBranch = async () => {
const editing = branch.schemaMetadata
? cloneDeep(branch.schemaMetadata)
: DatabaseMetadata.fromPartial({});
- await applyMetadataEdit(database.value, editing);
+ applyMetadataEdit(database.value, editing);
const validationMessages = validateDatabaseMetadata(editing);
if (validationMessages.length > 0) {
diff --git a/frontend/src/components/Branch/SchemaDesignEditorLite.vue b/frontend/src/components/Branch/SchemaDesignEditorLite.vue
index a8ba7c922e..65da8869c6 100644
--- a/frontend/src/components/Branch/SchemaDesignEditorLite.vue
+++ b/frontend/src/components/Branch/SchemaDesignEditorLite.vue
@@ -135,7 +135,7 @@ const generateDDL = async (silent: boolean) => {
const editing = props.branch.schemaMetadata
? cloneDeep(props.branch.schemaMetadata)
: DatabaseMetadata.fromPartial({});
- await applyMetadataEdit(database.value, editing);
+ applyMetadataEdit(database.value, editing);
const result = await generateDiffDDL(database.value, source, editing);
if (result.fatal && !silent) {
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
index 34d52c3626..9cc7267ee4 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
@@ -1,11 +1,8 @@
<template>
- <NEllipsis
- class="space-x-1"
- expand-trigger="click"
- line-clamp="2"
- :tooltip="false"
- >
- <span>{{ comment }}</span>
+ <div class="flex flex-col xl:flex-row xl:items-center xl:space-x-1">
+ <NEllipsis expand-trigger="click" line-clamp="2" :tooltip="false">
+ <span>{{ comment }}</span>
+ </NEllipsis>
<template v-if="commentLink.link">
<template v-if="commentLink.link.startsWith('/')">
<router-link class="inline normal-link" :to="commentLink.link">
@@ -23,7 +20,7 @@
</a>
</template>
</template>
- </NEllipsis>
+ </div>
</template>
<script setup lang="tsx">
diff --git a/frontend/src/components/SQLCheck/SQLCheckButton.vue b/frontend/src/components/SQLCheck/SQLCheckButton.vue
index 8ad224cfe5..3c737d7b93 100644
--- a/frontend/src/components/SQLCheck/SQLCheckButton.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckButton.vue
@@ -61,6 +61,7 @@
:confirm="confirmDialog"
:override-title="$t('issue.sql-check.sql-review-violations')"
:show-code-location="showCodeLocation"
+ :allow-force-continue="allowForceContinue"
:ignore-issue-creation-restriction="ignoreIssueCreationRestriction"
@close="onPanelClose"
>
@@ -95,7 +96,11 @@ import { useSQLCheckContext } from "./context";
const props = withDefaults(
defineProps<{
- getStatement: () => Promise<{ errors: string[]; statement: string }>;
+ getStatement: () => Promise<{
+ errors: string[];
+ statement: string;
+ fatal?: boolean;
+ }>;
database: ComposedDatabase;
databaseMetadata?: DatabaseMetadata;
buttonProps?: ButtonProps;
@@ -125,6 +130,7 @@ const { t } = useI18n();
const SKIP_CHECK_THRESHOLD = 1024 * 1024;
const isRunning = ref(false);
const showDetailPanel = ref(false);
+const allowForceContinue = ref(true);
const rawAdvices = ref<Advice[]>();
const context = useSQLCheckContext();
const confirmDialog = ref<Defer<boolean>>();
@@ -209,7 +215,7 @@ const runChecks = async () => {
rawAdvices.value = errors.map((err) =>
Advice.fromPartial({
title: "Pre check",
- status: Advice_Status.WARNING,
+ status: Advice_Status.ERROR,
content: err,
})
);
@@ -220,7 +226,9 @@ const runChecks = async () => {
if (!rawAdvices.value) {
rawAdvices.value = [];
}
- const { statement, errors } = await props.getStatement();
+ const { statement, errors, fatal } = await props.getStatement();
+ allowForceContinue.value = !fatal;
+
if (statement.length > SKIP_CHECK_THRESHOLD) {
return handleErrors([t("issue.sql-check.statement-is-too-large")]);
}
diff --git a/frontend/src/components/SQLCheck/SQLCheckPanel.vue b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
index 753bd12b8e..e16adb6718 100644
--- a/frontend/src/components/SQLCheck/SQLCheckPanel.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
@@ -26,7 +26,7 @@
{{ $t("issue.sql-check.back-to-edit") }}
</NButton>
<NButton
- v-if="!restrictIssueCreationForSQLReview"
+ v-if="allowForceContinue && !restrictIssueCreationForSQLReview"
type="primary"
@click="confirm!.resolve(true)"
>
@@ -55,13 +55,19 @@ import type { Advice } from "@/types/proto/v1/sql_service";
import { Advice_Status } from "@/types/proto/v1/sql_service";
import type { Defer } from "@/utils";
-const props = defineProps<{
- database: ComposedDatabase;
- advices: Advice[];
- overrideTitle?: string;
- confirm?: Defer<boolean>;
- showCodeLocation?: boolean;
-}>();
+const props = withDefaults(
+ defineProps<{
+ database: ComposedDatabase;
+ advices: Advice[];
+ overrideTitle?: string;
+ confirm?: Defer<boolean>;
+ showCodeLocation?: boolean;
+ allowForceContinue?: boolean;
+ }>(),
+ {
+ allowForceContinue: true,
+ }
+);
defineEmits<{
(event: "close"): void;
diff --git a/frontend/src/components/SchemaEditorLite/common.ts b/frontend/src/components/SchemaEditorLite/common.ts
index e60eabc545..242a6f75f2 100644
--- a/frontend/src/components/SchemaEditorLite/common.ts
+++ b/frontend/src/components/SchemaEditorLite/common.ts
@@ -42,7 +42,7 @@ export const generateDiffDDL = async (
return finish(
"",
[t("schema-editor.message.invalid-schema"), ...validationMessages],
- false
+ true
);
}
try {
diff --git a/frontend/src/components/SchemaEditorLite/utils/metadata.ts b/frontend/src/components/SchemaEditorLite/utils/metadata.ts
index 9606ba1599..6b93dc447b 100644
--- a/frontend/src/components/SchemaEditorLite/utils/metadata.ts
+++ b/frontend/src/components/SchemaEditorLite/utils/metadata.ts
@@ -15,11 +15,11 @@ export const validateDatabaseMetadata = (
for (const column of table.columns) {
if (!column.name) {
- messages.push(`Column name is required.`);
+ messages.push(`Column name is required in table ${table.name}`);
continue;
}
if (!column.type) {
- messages.push(`Column ${column.name} type is required.`);
+ messages.push(`Missing column type in ${table.name}.${column.name}`);
}
}
}