Skip to content

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

fix: find engine type in schema editor (#8344)

ecmadao8f080a5f247f
diff --git a/frontend/src/components/SchemaEditorV1/Modals/EditColumnForeignKeyModal.vue b/frontend/src/components/SchemaEditorV1/Modals/EditColumnForeignKeyModal.vue
index 550bb0ee93..8802c0928b 100644
--- a/frontend/src/components/SchemaEditorV1/Modals/EditColumnForeignKeyModal.vue
+++ b/frontend/src/components/SchemaEditorV1/Modals/EditColumnForeignKeyModal.vue
@@ -76,9 +76,8 @@ import { isUndefined } from "lodash-es";
import { computed, onMounted, reactive, watch } from "vue";
import { BBModal, BBSelect } from "@/bbkit";
import { useSchemaEditorV1Store } from "@/store";
-import { Column, ComposedDatabase, ForeignKey } from "@/types";
import { Engine } from "@/types/proto/v1/common";
-import { SchemaDesign } from "@/types/proto/v1/schema_design_service";
+import { Column, ForeignKey } from "@/types/v1/schemaEditor";
interface LocalState {
referencedSchemaId?: string;
@@ -102,20 +101,8 @@ const state = reactive<LocalState>({
referencedSchemaId: props.schemaId,
});
-const parentResouce = computed(() => {
- return schemaEditorV1Store.resourceMap[schemaEditorV1Store.resourceType].get(
- props.parentName
- )!;
-});
const engine = computed(() => {
- if (schemaEditorV1Store.resourceType === "branch") {
- return (parentResouce.value as any as SchemaDesign).engine;
- } else if (schemaEditorV1Store.resourceType === "database") {
- return (parentResouce.value as any as ComposedDatabase).instanceEntity
- .engine;
- } else {
- return Engine.MYSQL;
- }
+ return schemaEditorV1Store.getCurrentEngine(props.parentName);
});
const parentResource = computed(() => {
diff --git a/frontend/src/components/SchemaEditorV1/Modals/TableNameModal.vue b/frontend/src/components/SchemaEditorV1/Modals/TableNameModal.vue
index e574183edf..5ca1b7299a 100644
--- a/frontend/src/components/SchemaEditorV1/Modals/TableNameModal.vue
+++ b/frontend/src/components/SchemaEditorV1/Modals/TableNameModal.vue
@@ -43,8 +43,6 @@ import {
TableMetadata,
} from "@/types/proto/v1/database_service";
import {
- BranchSchema,
- DatabaseSchema,
SchemaEditorTabType,
convertColumnMetadataToColumn,
convertTableMetadataToTable,
@@ -73,21 +71,8 @@ const state = reactive<LocalState>({
tableName: "",
});
-const parentResouce = computed(() => {
- return schemaEditorV1Store.resourceMap[schemaEditorV1Store.resourceType].get(
- props.parentName
- )!;
-});
-
const engine = computed(() => {
- if (schemaEditorV1Store.resourceType === "branch") {
- return (parentResouce.value as BranchSchema).branch.engine;
- } else if (schemaEditorV1Store.resourceType === "database") {
- return (parentResouce.value as DatabaseSchema).database.instanceEntity
- .engine;
- } else {
- return Engine.MYSQL;
- }
+ return schemaEditorV1Store.getCurrentEngine(props.parentName);
});
const isCreatingTable = computed(() => {
diff --git a/frontend/src/components/SchemaEditorV1/Panels/TableEditor.vue b/frontend/src/components/SchemaEditorV1/Panels/TableEditor.vue
index 01ad321437..bb08348915 100644
--- a/frontend/src/components/SchemaEditorV1/Panels/TableEditor.vue
+++ b/frontend/src/components/SchemaEditorV1/Panels/TableEditor.vue
@@ -329,13 +329,7 @@ const parentResouce = computed(() => {
)!;
});
const engine = computed(() => {
- if (schemaEditorV1Store.resourceType === "branch") {
- return (parentResouce.value as any).branch.engine;
- } else if (schemaEditorV1Store.resourceType === "database") {
- return (parentResouce.value as any).database.instanceEntity.engine;
- } else {
- return Engine.MYSQL;
- }
+ return schemaEditorV1Store.getCurrentEngine(currentTab.value.parentName);
});
const readonly = computed(() => schemaEditorV1Store.readonly);
const project = computed(() => schemaEditorV1Store.project);
diff --git a/frontend/src/store/modules/v1/schemaEditor.ts b/frontend/src/store/modules/v1/schemaEditor.ts
index 60a7c888c1..783f5b859d 100644
--- a/frontend/src/store/modules/v1/schemaEditor.ts
+++ b/frontend/src/store/modules/v1/schemaEditor.ts
@@ -1,7 +1,10 @@
import { isUndefined, uniqueId } from "lodash-es";
import { defineStore } from "pinia";
import { ComposedDatabase, emptyProject } from "@/types";
+import { Engine } from "@/types/proto/v1/common";
import {
+ BranchSchema,
+ DatabaseSchema,
SchemaEditorV1State,
Table,
TabContext,
@@ -50,6 +53,19 @@ export const useSchemaEditorV1Store = defineStore("SchemaEditorV1", {
},
},
actions: {
+ getCurrentEngine(parentName: string) {
+ const parentResouce = this.resourceMap[this.resourceType].get(parentName);
+ if (!parentResouce) {
+ return Engine.MYSQL;
+ }
+ if (this.resourceType === "database") {
+ return (parentResouce as DatabaseSchema).database.instanceEntity.engine;
+ } else if (this.resourceType === "branch") {
+ return (parentResouce as BranchSchema).branch.engine;
+ } else {
+ return Engine.MYSQL;
+ }
+ },
setState(state: Partial<SchemaEditorV1State>) {
Object.assign(this, state);
},