Skip to content

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

chore: update column default value input handler (#8874)

boojackf93b108782c8
diff --git a/frontend/src/components/SchemaEditorV1/Panels/TableColumnEditor.vue b/frontend/src/components/SchemaEditorV1/Panels/TableColumnEditor.vue
index 73b44389d6..6d2dfb0e24 100644
--- a/frontend/src/components/SchemaEditorV1/Panels/TableColumnEditor.vue
+++ b/frontend/src/components/SchemaEditorV1/Panels/TableColumnEditor.vue
@@ -307,6 +307,7 @@ import {
getColumnDefaultValuePlaceholder,
getDefaultValueByKey,
getColumnDefaultValueOptions,
+ isTextOfColumnType,
} from "../utils/columnDefaultValue";
interface LocalState {
@@ -501,11 +502,16 @@ const handleColumnDefaultInputChange = (event: Event, column: Column) => {
const value = (event.target as HTMLInputElement).value;
column.hasDefault = true;
column.defaultNull = undefined;
- if (column.defaultString !== undefined) {
+ // If column is text type or has default string, we will treat user's input as string.
+ if (
+ isTextOfColumnType(props.engine, column.type) ||
+ column.defaultString !== undefined
+ ) {
column.defaultString = value;
+ column.defaultExpression = undefined;
return;
}
- // By default, user input is treated as expression.
+ // Otherwise we will treat user's input as expression.
column.defaultExpression = value;
};
diff --git a/frontend/src/components/SchemaEditorV1/utils/columnDefaultValue.ts b/frontend/src/components/SchemaEditorV1/utils/columnDefaultValue.ts
index a215b9003a..4d0ef9da81 100644
--- a/frontend/src/components/SchemaEditorV1/utils/columnDefaultValue.ts
+++ b/frontend/src/components/SchemaEditorV1/utils/columnDefaultValue.ts
@@ -61,6 +61,18 @@ const BOOLEAN_FALSE_OPTION: DefaultValueOption = {
},
};
+export const isTextOfColumnType = (_: Engine, columnType: string) => {
+ const type = columnType.toUpperCase();
+ if (
+ type === "TEXT" ||
+ type.startsWith("VARCHAR") ||
+ type.startsWith("CHAR")
+ ) {
+ return true;
+ }
+ return false;
+};
+
export const getColumnTypeDefaultValueOptions = (
engine: Engine,
columnType: string