Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: use simple input block for PostgreSQL column default in schema editor (#16718)
h3n4l562d176ae0c4
diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DefaultValueCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DefaultValueCell.vueindex 766f51a115..d447086afb 100644--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DefaultValueCell.vue+++ b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DefaultValueCell.vue@@ -1,5 +1,19 @@<template>+ <!-- TODO: When all engines migrate to simplified input, replace NInput with InlineInput component -->+ <NInput+ v-if="useSimpleInput"+ ref="inputRef"+ :value="postgresInputValue"+ :placeholder="postgresPlaceholder"+ :disabled="disabled"+ :style="simpleInputStyle"+ @focus="focused = true"+ @blur="focused = false"+ @update:value="handlePostgresInput"+ />+<NDropdown+ v-elsetrigger="click"placement="bottom-start":value="dropdownValue"@@ -69,7 +83,7 @@ import {getColumnDefaultDisplayString,getColumnDefaultValuePlaceholder,} from "@/components/SchemaEditorLite/utils";-import type { Engine } from "@/types/proto-es/v1/common_pb";+import { Engine } from "@/types/proto-es/v1/common_pb";import type { ColumnMetadata } from "@/types/proto-es/v1/database_service_pb";type DefaultValueSelectOption = SelectOption & {@@ -109,6 +123,40 @@ const placeholder = computed(() => {return getColumnDefaultValuePlaceholder(props.column);});+// Computed property for engines that use simple input (currently PostgreSQL)+const useSimpleInput = computed(() => {+ return props.engine === Engine.POSTGRES;+});++const postgresInputValue = computed(() => {+ // For PostgreSQL, we use defaultString field which contains the schema-qualified expression+ return props.column.defaultString || "";+});++const postgresPlaceholder = computed(() => {+ return t("schema-editor.default.postgres-placeholder");+});++// TODO: This styling mimics InlineInput component. When all engines use simplified input,+// replace NInput + simpleInputStyle with InlineInput component directly+const simpleInputStyle = computed(() => {+ const style: CSSProperties = {+ cursor: "default",+ "--n-color": "transparent",+ "--n-color-disabled": "transparent",+ "--n-padding-left": "6px",+ "--n-padding-right": "4px",+ "--n-text-color-disabled": "rgb(var(--color-main))",+ };+ const border = focused.value+ ? "1px solid rgb(var(--color-control-border))"+ : "none";+ style["--n-border"] = border;+ style["--n-border-disabled"] = border;++ return style;+});+const options = computed((): DefaultValueSelectOption[] => {return [{@@ -169,6 +217,23 @@ const handleInput = (value: string) => {emit("input", value);};+const handlePostgresInput = (value: string) => {+ // For PostgreSQL, emit the value for the input handler+ emit("input", value);++ // Also emit a select event to maintain consistency with the existing API+ const defaultOption = {+ key: value.trim() ? "string" : "no-default",+ value: {+ hasDefault: !!value.trim(),+ defaultNull: false,+ defaultString: value.trim(), // For PostgreSQL, store in defaultString+ defaultExpression: "",+ },+ };+ emit("select", defaultOption);+};+const inputStyle = computed(() => {const style: CSSProperties = {"--n-padding-left": "6px",diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex d3e4bb4aae..1a19efe210 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2062,7 +2062,8 @@"no-default": "No default","expression": "Expression","null": "NULL",- "value": "Value"+ "value": "Value",+ "postgres-placeholder": "Enter default expression (e.g., 'hello', 42, now(), nextval('seq')) or leave empty for no default"},"message": {"invalid-schema-name": "Invalid schema name",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex e59746176b..66cf84b056 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2062,7 +2062,8 @@"no-default": "Sin valor predeterminado","expression": "Expresión","null": "NULL",- "value": "Valor"+ "value": "Valor",+ "postgres-placeholder": "Ingrese una expresión predeterminada (por ejemplo, 'hola', 42, now(), nextval('seq')) o déjela vacía si no hay una expresión predeterminada"},"message": {"invalid-schema-name": "Nombre de esquema inválido",@@ -2801,4 +2802,4 @@"last-visit": "Última visita","changelog-for-version": "Registro de cambios para {version}"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 6112131498..daac6b5bab 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2062,7 +2062,8 @@"no-default": "デフォルト値なし","expression": "式","null": "NULL",- "value": "値"+ "value": "値",+ "postgres-placeholder": "デフォルトの式(例:'hello'、42、now()、nextval('seq'))を入力するか、デフォルトがない場合は空白のままにしてください"},"message": {"invalid-schema-name": "無効なスキーマ名",@@ -2801,4 +2802,4 @@"last-visit": "最終訪問","changelog-for-version": "{version} の変更履歴"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex d32569f896..55411b763c 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -2062,7 +2062,8 @@"no-default": "Không mặc định","expression": "Biểu thức","null": "NULL",- "value": "Giá trị"+ "value": "Giá trị",+ "postgres-placeholder": "Nhập biểu thức mặc định (ví dụ: 'hello', 42, now(), nextval('seq')) hoặc để trống nếu không có biểu thức mặc định"},"message": {"invalid-schema-name": "Tên lược đồ không hợp lệ",@@ -2801,4 +2802,4 @@"last-visit": "Lần truy cập cuối","changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex aa2936593c..c7a5963709 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2062,7 +2062,8 @@"no-default": "无默认值","expression": "表达式","null": "NULL",- "value": "值"+ "value": "值",+ "postgres-placeholder": "输入默认表达式(例如,'hello'、42、now()、nextval('seq'))或留空表示无默认值"},"message": {"invalid-schema-name": "无效的 Schema 名称",@@ -2801,4 +2802,4 @@"last-visit": "上次访问","changelog-for-version": "{version} 的更新日志"}-}+}\ No newline at end of file