mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-29 08:11:06 +00:00
fix(db): normalize default database handling
This commit is contained in:
@@ -157,7 +157,7 @@ const driverProfiles: Record<
|
||||
icon: "starrocks",
|
||||
urlParams: "",
|
||||
},
|
||||
redshift: { type: "postgres", port: 5439, user: "awsuser", label: "Redshift", icon: "redshift" },
|
||||
redshift: { type: "redshift", port: 5439, user: "awsuser", label: "Redshift", icon: "redshift" },
|
||||
cockroachdb: {
|
||||
type: "postgres",
|
||||
port: 26257,
|
||||
@@ -273,6 +273,26 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
const databaseLabel = computed(() =>
|
||||
form.value.db_type === "oracle" ? t("connection.serviceName") : t("connection.database"),
|
||||
);
|
||||
|
||||
const databasePlaceholder = computed(() => {
|
||||
const fallback = defaultDatabaseForProfile();
|
||||
if (!fallback) return t("connection.databasePlaceholder");
|
||||
return t("connection.databasePlaceholderWithDefault", { database: fallback });
|
||||
});
|
||||
|
||||
function defaultDatabaseForProfile() {
|
||||
if (form.value.db_type === "redshift") return "dev";
|
||||
if (form.value.db_type === "gaussdb") return "postgres";
|
||||
if (selectedType.value === "cockroachdb") return "defaultdb";
|
||||
if (form.value.db_type === "postgres") return "postgres";
|
||||
if (form.value.db_type === "sqlserver") return "master";
|
||||
if (form.value.db_type === "oracle") return "ORCL";
|
||||
return "";
|
||||
}
|
||||
|
||||
function onDbTypeChange(val: string) {
|
||||
customDriverName.value = "";
|
||||
applyProfile(val, !!editingId.value);
|
||||
@@ -821,12 +841,8 @@ async function browseDbFilePath() {
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
<Label class="text-right">{{ t("connection.database") }}</Label>
|
||||
<Input
|
||||
v-model="form.database"
|
||||
class="col-span-3"
|
||||
:placeholder="t('connection.databasePlaceholder')"
|
||||
/>
|
||||
<Label class="text-right">{{ databaseLabel }}</Label>
|
||||
<Input v-model="form.database" class="col-span-3" :placeholder="databasePlaceholder" />
|
||||
</div>
|
||||
|
||||
<div v-if="selectedType === 'dm'" class="grid grid-cols-4 items-center gap-4">
|
||||
@@ -852,14 +868,14 @@ async function browseDbFilePath() {
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="form.db_type === 'mysql' || form.db_type === 'postgres'"
|
||||
v-if="form.db_type === 'mysql' || form.db_type === 'postgres' || form.db_type === 'redshift'"
|
||||
class="grid grid-cols-4 items-center gap-4"
|
||||
>
|
||||
<Label class="text-right">{{ t("connection.urlParams") }}</Label>
|
||||
<Input
|
||||
v-model="form.url_params"
|
||||
class="col-span-3"
|
||||
:placeholder="form.db_type === 'postgres' ? 'sslmode=disable' : 'charset=utf8mb4'"
|
||||
:placeholder="form.db_type === 'mysql' ? 'charset=utf8mb4' : 'sslmode=disable'"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -75,6 +75,8 @@ export default {
|
||||
password: "Password",
|
||||
database: "Database",
|
||||
databasePlaceholder: "Optional",
|
||||
databasePlaceholderWithDefault: "Optional, defaults to {database}",
|
||||
serviceName: "Service/SID",
|
||||
driverName: "Driver Name",
|
||||
driverNamePlaceholder: "Vendor or environment name",
|
||||
urlParams: "URL Params",
|
||||
|
||||
@@ -74,6 +74,8 @@ export default {
|
||||
password: "密码",
|
||||
database: "数据库",
|
||||
databasePlaceholder: "可选",
|
||||
databasePlaceholderWithDefault: "可选,默认 {database}",
|
||||
serviceName: "服务名/SID",
|
||||
driverName: "驱动名称",
|
||||
driverNamePlaceholder: "厂商或环境名称",
|
||||
urlParams: "URL 参数",
|
||||
|
||||
@@ -78,7 +78,7 @@ export const FIELD_LINEAGE_SUPPORTED_TYPES = new Set<DatabaseType>([
|
||||
|
||||
export const FETCH_FIRST_TYPES = new Set<DatabaseType>(["oracle", "dameng"]);
|
||||
|
||||
export const TREE_SCHEMA_TYPES = new Set<DatabaseType>(["postgres", "sqlserver", "gaussdb"]);
|
||||
export const TREE_SCHEMA_TYPES = new Set<DatabaseType>(["postgres", "redshift", "sqlserver", "gaussdb"]);
|
||||
|
||||
export const PG_LIKE_STRUCTURE_TYPES = new Set<DatabaseType>(["postgres", "redshift", "gaussdb"]);
|
||||
|
||||
|
||||
@@ -138,6 +138,8 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
let dbType = config.db_type;
|
||||
if ((profile === "gaussdb" || profile === "opengauss") && dbType === "postgres") {
|
||||
dbType = "gaussdb" as ConnectionConfig["db_type"];
|
||||
} else if (profile === "redshift" && dbType === "postgres") {
|
||||
dbType = "redshift" as ConnectionConfig["db_type"];
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user