Skip to content

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

Hide character set and collation for ClickHouse

天舟0fab27b3d849
diff --git a/frontend/src/components/ColumnTable.vue b/frontend/src/components/ColumnTable.vue
index a7d38ae670..dc1b682d08 100644
--- a/frontend/src/components/ColumnTable.vue
+++ b/frontend/src/components/ColumnTable.vue
@@ -1,6 +1,6 @@
<template>
<BBTable
- :columnList="COLUMN_LIST"
+ :columnList="columnNameList"
:dataSource="columnList"
:showHeader="true"
:leftBordered="true"
@@ -19,10 +19,13 @@
<BBTableCell class="w-8">
{{ column.nullable }}
</BBTableCell>
- <BBTableCell v-if="engine != 'POSTGRES'" class="w-8">
+ <BBTableCell
+ v-if="engine != 'POSTGRES' && engine != 'CLICKHOUSE'"
+ class="w-8"
+ >
{{ column.characterSet }}
</BBTableCell>
- <BBTableCell class="w-8">
+ <BBTableCell v-if="engine != 'CLICKHOUSE'" class="w-8">
{{ column.collation }}
</BBTableCell>
<BBTableCell class="w-16">
@@ -33,7 +36,7 @@
</template>
<script lang="ts">
-import { PropType } from "vue";
+import { computed, PropType } from "vue";
import { BBTableColumn } from "../bbkit/types";
import { Column, EngineType } from "../types";
@@ -82,6 +85,24 @@ const POSTGRES_COLUMN_LIST: BBTableColumn[] = [
},
];
+const CLICKHOUSE_COLUMN_LIST: BBTableColumn[] = [
+ {
+ title: "Name",
+ },
+ {
+ title: "Type",
+ },
+ {
+ title: "Default",
+ },
+ {
+ title: "Nullable",
+ },
+ {
+ title: "Comment",
+ },
+];
+
export default {
name: "ColumnTable",
components: {},
@@ -96,9 +117,18 @@ export default {
},
},
setup(props, ctx) {
+ const columnNameList = computed(() => {
+ switch (props.engine) {
+ case "POSTGRES":
+ return POSTGRES_COLUMN_LIST;
+ case "CLICKHOUSE":
+ return CLICKHOUSE_COLUMN_LIST;
+ default:
+ return NORMAL_COLUMN_LIST;
+ }
+ });
return {
- COLUMN_LIST:
- props.engine == "POSTGRES" ? POSTGRES_COLUMN_LIST : NORMAL_COLUMN_LIST,
+ columnNameList,
};
},
};
diff --git a/frontend/src/components/CreateDatabasePrepForm.vue b/frontend/src/components/CreateDatabasePrepForm.vue
index 6e3c2d0dfb..844fbe4498 100644
--- a/frontend/src/components/CreateDatabasePrepForm.vue
+++ b/frontend/src/components/CreateDatabasePrepForm.vue
@@ -69,33 +69,39 @@
</div>
</div>
- <div class="col-span-2 col-start-2 w-64">
- <label for="charset" class="textlabel">
- {{
- selectedInstance.engine == "POSTGRES" ? "Encoding" : "Character set"
- }}</label
- >
- <input
- id="charset"
- name="charset"
- type="text"
- class="textfield mt-1 w-full"
- :placeholder="defaultCharset(selectedInstance.engine)"
- v-model="state.characterSet"
- />
- </div>
+ <template v-if="selectedInstance.engine != 'CLICKHOUSE'">
+ <div class="col-span-2 col-start-2 w-64">
+ <label for="charset" class="textlabel">
+ {{
+ selectedInstance.engine == "POSTGRES"
+ ? "Encoding"
+ : "Character set"
+ }}</label
+ >
+ <input
+ id="charset"
+ name="charset"
+ type="text"
+ class="textfield mt-1 w-full"
+ :placeholder="defaultCharset(selectedInstance.engine)"
+ v-model="state.characterSet"
+ />
+ </div>
- <div class="col-span-2 col-start-2 w-64">
- <label for="collation" class="textlabel"> Collation </label>
- <input
- id="collation"
- name="collation"
- type="text"
- class="textfield mt-1 w-full"
- :placeholder="defaultCollation(selectedInstance.engine) || 'default'"
- v-model="state.collation"
- />
- </div>
+ <div class="col-span-2 col-start-2 w-64">
+ <label for="collation" class="textlabel"> Collation </label>
+ <input
+ id="collation"
+ name="collation"
+ type="text"
+ class="textfield mt-1 w-full"
+ :placeholder="
+ defaultCollation(selectedInstance.engine) || 'default'
+ "
+ v-model="state.collation"
+ />
+ </div>
+ </template>
<div v-if="showAssigneeSelect" class="col-span-2 col-start-2 w-64">
<label for="user" class="textlabel">
diff --git a/frontend/src/components/DatabaseOverviewPanel.vue b/frontend/src/components/DatabaseOverviewPanel.vue
index 9a9d34c18f..69cf7e42f3 100644
--- a/frontend/src/components/DatabaseOverviewPanel.vue
+++ b/frontend/src/components/DatabaseOverviewPanel.vue
@@ -33,25 +33,27 @@
<!-- Description list -->
<dl class="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2 pt-4">
- <div class="col-span-1 col-start-1">
- <dt class="text-sm font-medium text-control-light">
- {{
- database.instance.engine == "POSTGRES"
- ? "Encoding"
- : "Character set"
- }}
- </dt>
- <dd class="mt-1 text-sm text-main">
- {{ database.characterSet }}
- </dd>
- </div>
+ <template v-if="database.instance.engine != 'CLICKHOUSE'">
+ <div class="col-span-1 col-start-1">
+ <dt class="text-sm font-medium text-control-light">
+ {{
+ database.instance.engine == "POSTGRES"
+ ? "Encoding"
+ : "Character set"
+ }}
+ </dt>
+ <dd class="mt-1 text-sm text-main">
+ {{ database.characterSet }}
+ </dd>
+ </div>
- <div class="col-span-1">
- <dt class="text-sm font-medium text-control-light">Collation</dt>
- <dd class="mt-1 text-sm text-main">
- {{ database.collation }}
- </dd>
- </div>
+ <div class="col-span-1">
+ <dt class="text-sm font-medium text-control-light">Collation</dt>
+ <dd class="mt-1 text-sm text-main">
+ {{ database.collation }}
+ </dd>
+ </div>
+ </template>
<div class="col-span-1 col-start-1">
<dt class="text-sm font-medium text-control-light">Sync status</dt>
diff --git a/frontend/src/types/instance.ts b/frontend/src/types/instance.ts
index 3408771d18..43d5aa1157 100644
--- a/frontend/src/types/instance.ts
+++ b/frontend/src/types/instance.ts
@@ -10,6 +10,7 @@ export type EngineType = "CLICKHOUSE" | "MYSQL" | "POSTGRES" | "TIDB";
export function defaultCharset(type: EngineType): string {
switch (type) {
case "CLICKHOUSE":
+ return "";
case "MYSQL":
case "TIDB":
return "utf8mb4";
@@ -21,6 +22,7 @@ export function defaultCharset(type: EngineType): string {
export function defaultCollation(type: EngineType): string {
switch (type) {
case "CLICKHOUSE":
+ return "";
case "MYSQL":
case "TIDB":
return "utf8mb4_general_ci";
diff --git a/frontend/src/views/TableDetail.vue b/frontend/src/views/TableDetail.vue
index c53fef566f..f3464b752d 100644
--- a/frontend/src/views/TableDetail.vue
+++ b/frontend/src/views/TableDetail.vue
@@ -143,29 +143,33 @@
</dd>
</div>
- <div class="col-span-1 col-start-1">
- <dt class="text-sm font-medium text-control-light">
- {{
- database.instance.engine == "POSTGRES"
- ? "Encoding"
- : "Character set"
- }}
- </dt>
- <dd class="mt-1 text-sm text-main">
- {{ database.characterSet }}
- </dd>
- </div>
+ <template v-if="database.instance.engine != 'CLICKHOUSE'">
+ <div class="col-span-1 col-start-1">
+ <dt class="text-sm font-medium text-control-light">
+ {{
+ database.instance.engine == "POSTGRES"
+ ? "Encoding"
+ : "Character set"
+ }}
+ </dt>
+ <dd class="mt-1 text-sm text-main">
+ {{ database.characterSet }}
+ </dd>
+ </div>
- <div class="col-span-1">
- <dt class="text-sm font-medium text-control-light">Collation</dt>
- <dd class="mt-1 text-sm text-main">
- {{
- database.instance.engine == "POSTGRES"
- ? "n/a"
- : table.collation
- }}
- </dd>
- </div>
+ <div class="col-span-1">
+ <dt class="text-sm font-medium text-control-light">
+ Collation
+ </dt>
+ <dd class="mt-1 text-sm text-main">
+ {{
+ database.instance.engine == "POSTGRES"
+ ? "n/a"
+ : table.collation
+ }}
+ </dd>
+ </div>
+ </template>
<div class="col-span-1 col-start-1">
<dt class="text-sm font-medium text-control-light">Updated</dt>
diff --git a/server/issue.go b/server/issue.go
index 405b538981..4255854c80 100644
--- a/server/issue.go
+++ b/server/issue.go
@@ -40,9 +40,6 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {
if taskCreate.DatabaseName == "" {
return echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, database name missing")
}
- if taskCreate.CharacterSet == "" {
- return echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, character set missing")
- }
instanceFind := &api.InstanceFind{
ID: &taskCreate.InstanceId,
}
@@ -50,11 +47,30 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create issue.").SetInternal(err)
}
- // For postgres, we don't explicitly specify a default since the default might be UNSET (denoted by "C").
- // If that's the case, setting an explicit default such as "en_US.UTF-8" might fail if the instance doesn't
- // install it.
- if instance.Engine != db.Postgres && taskCreate.Collation == "" {
- return echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, collation missing")
+ // ClickHouse does not support character set and collation at the database level.
+ if instance.Engine == db.ClickHouse {
+ if taskCreate.CharacterSet != "" {
+ return echo.NewHTTPError(
+ http.StatusBadRequest,
+ fmt.Sprintf("Failed to create issue, ClickHouse does not support character set, got %s\n", taskCreate.CharacterSet),
+ )
+ }
+ if taskCreate.Collation != "" {
+ return echo.NewHTTPError(
+ http.StatusBadRequest,
+ fmt.Sprintf("Failed to create issue, ClickHouse does not support collation, got %s\n", taskCreate.Collation),
+ )
+ }
+ } else {
+ if taskCreate.CharacterSet == "" {
+ return echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, character set missing")
+ }
+ // For postgres, we don't explicitly specify a default since the default might be UNSET (denoted by "C").
+ // If that's the case, setting an explicit default such as "en_US.UTF-8" might fail if the instance doesn't
+ // install it.
+ if instance.Engine != db.Postgres && taskCreate.Collation == "" {
+ return echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, collation missing")
+ }
}
} else if taskCreate.Type == api.TaskDatabaseSchemaUpdate {
if taskCreate.Statement == "" {