Skip to content

Commit 7834f47

Browse files
committed
feat: add Dameng database client support
1 parent 4009ce9 commit 7834f47

17 files changed

Lines changed: 60 additions & 9 deletions

‎ui/chen/utils/sqlEditor.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { CompletionSource } from "@codemirror/autocomplete";
22

33
import { CompletionContext } from "@codemirror/autocomplete";
4-
import { PostgreSQL, sql } from "@codemirror/lang-sql";
4+
import { PLSQL, PostgreSQL, sql } from "@codemirror/lang-sql";
55
import { EditorState } from "@codemirror/state";
66
import { describe, expect, it } from "vitest";
77
import {
88
chenSqlExtensions,
9+
chenSqlDialect,
910
chenSqlStatementAtCursor,
1011
chenSqlStatementRanges,
1112
executableChenSql
@@ -50,6 +51,11 @@ describe("sql editor execution targets", () => {
5051
});
5152

5253
describe("sql editor keyword completion", () => {
54+
it("uses the PL/SQL grammar for Dameng protocol names", () => {
55+
expect(chenSqlDialect("dameng")).toBe(PLSQL);
56+
expect(chenSqlDialect("dm")).toBe(PLSQL);
57+
});
58+
5359
async function completionLabels(keywordCase: "lower" | "upper") {
5460
const state = EditorState.create({
5561
doc: "sel",

‎ui/chen/utils/sqlEditor.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export function chenSqlDialect(dbType: string) {
2020
case "postgresql":
2121
return PostgreSQL;
2222
case "oracle":
23+
case "dameng":
24+
case "dm":
2325
return PLSQL;
2426
case "sqlserver":
2527
case "sql server":

‎ui/chen/utils/sqlFormat.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const formatterLanguageMap = {
1111
db2: "db2",
1212
// ponytail: Dameng reuses PL/SQL only for display formatting. Add a dedicated
1313
// formatter before supporting stored procedures or Dameng-specific DDL.
14-
dameng: "plsql"
14+
dameng: "plsql",
15+
dm: "plsql"
1516
} as const;
1617

1718
export function formatChenSql(statement: string, dbType: string) {

‎ui/components/ScriptEditor.client.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function languageExtension(module: string): Extension {
2727
if (module === "mariadb") return sql({ dialect: MariaSQL });
2828
if (module === "postgresql") return sql({ dialect: PostgreSQL });
2929
if (module === "sqlserver") return sql({ dialect: MSSQL });
30-
if (module === "oracle") return sql({ dialect: PLSQL });
30+
if (["oracle", "dameng"].includes(module)) return sql({ dialect: PLSQL });
3131
return [];
3232
}
3333

‎ui/components/SideBar/assetTreeNode.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const typeGroupIcon = computed(() => {
6868
const hasExact = (...keywords: string[]) => iconCandidates.value.some((value) => keywords.includes(value));
6969
7070
if (has("k8s", "kubernetes", "container")) return "i-lucide-container";
71-
if (has("database", "mysql", "mariadb", "oracle", "postgres", "sqlserver", "redis", "mongodb", "db2")) {
71+
if (has("database", "mysql", "mariadb", "oracle", "dameng", "postgres", "sqlserver", "redis", "mongodb", "db2")) {
7272
return "i-lucide-database";
7373
}
7474
if (has("directory service", "directory_service", "directory-service", "windows_ad")) return "i-lucide-network";

‎ui/components/SideBar/bottomPanels.vue‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type PanelKind = "favorites" | "snippets";
2929
type SnippetGroupKey = "shell" | "win_shell" | "python" | "raw" | "database" | "other";
3030
3131
const FAVORITE_ROOT_ID = "__favorite_root__";
32-
const DATABASE_SNIPPET_MODULES = new Set(["mysql", "mariadb", "postgresql", "sqlserver", "oracle"]);
32+
const DATABASE_SNIPPET_MODULES = new Set(["mysql", "mariadb", "postgresql", "sqlserver", "oracle", "dameng"]);
3333
3434
const { t } = useI18n();
3535
const toast = useToast();
@@ -91,7 +91,8 @@ const snippetCreateItems = computed<DropdownMenuItem[]>(() =>
9191
["MariaDB", "mariadb", "i-lucide-database"],
9292
["PostgreSQL", "postgresql", "i-lucide-database"],
9393
["SQLServer", "sqlserver", "i-lucide-database"],
94-
["Oracle", "oracle", "i-lucide-database"]
94+
["Oracle", "oracle", "i-lucide-database"],
95+
["Dameng", "dameng", "i-lucide-database"]
9596
].map(([label, module, icon]) => ({
9697
label,
9798
icon,
@@ -342,6 +343,7 @@ function getSnippetIcon(snippet: Snippet) {
342343
case "postgresql":
343344
case "sqlserver":
344345
case "oracle":
346+
case "dameng":
345347
return "i-lucide-database";
346348
case "raw":
347349
return "i-lucide-file-text";

‎ui/koko/composables/terminal/terminalCommandSuggestions.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,23 @@ const CATALOGS: Record<KokoTerminalCommandProfile, string[]> = {
176176
"@",
177177
"EXIT"
178178
],
179+
dameng: [
180+
"SELECT",
181+
"INSERT",
182+
"UPDATE",
183+
"DELETE",
184+
"CREATE",
185+
"ALTER",
186+
"DROP",
187+
"DESC",
188+
"EXPLAIN",
189+
"SET",
190+
"COMMIT",
191+
"ROLLBACK",
192+
"CONNECT",
193+
"START",
194+
"EXIT"
195+
],
179196
sqlserver: [
180197
"SELECT",
181198
"INSERT",
@@ -205,14 +222,15 @@ const CASE_INSENSITIVE_PROFILES = new Set<KokoTerminalCommandProfile>([
205222
"redis",
206223
"mongodb",
207224
"oracle",
225+
"dameng",
208226
"sqlserver"
209227
]);
210228

211229
export function resolveTerminalCommandProfile(profile: ConnectorTerminalProfile = {}): KokoTerminalCommandProfile {
212230
const protocol = String(profile.protocol || "").toLowerCase();
213231
if (protocol === "mariadb" || protocol === "mysql") return "mysql";
214232
if (protocol === "pg" || protocol === "postgres" || protocol === "postgresql") return "postgresql";
215-
if (["redis", "mongodb", "oracle", "sqlserver"].includes(protocol)) {
233+
if (["redis", "mongodb", "oracle", "dameng", "sqlserver"].includes(protocol)) {
216234
return protocol as KokoTerminalCommandProfile;
217235
}
218236
const platform =

‎ui/koko/host.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type KokoTerminalCommandProfile =
3131
| "redis"
3232
| "mongodb"
3333
| "oracle"
34+
| "dameng"
3435
| "sqlserver";
3536

3637
const SENSITIVE_TERMINAL_COMMAND_PATTERNS = [

‎ui/koko/tests/terminal/terminalCommandSuggestions.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe("terminal command suggestions", () => {
1616
expect(resolveTerminalCommandProfile({ protocol: "mariadb" })).toBe("mysql");
1717
expect(resolveTerminalCommandProfile({ protocol: "pg" })).toBe("postgresql");
1818
expect(resolveTerminalCommandProfile({ protocol: "redis" })).toBe("redis");
19+
expect(resolveTerminalCommandProfile({ protocol: "dameng" })).toBe("dameng");
1920
expect(resolveTerminalCommandProfile({})).toBe("linux");
2021
});
2122

‎ui/shared/connectors/GuideSessionSurface.vue‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const defaultPorts: Record<string, number> = {
2929
postgresql: 5432,
3030
redis: 6379,
3131
oracle: 1521,
32+
dameng: 5236,
3233
sqlserver: 1433,
3334
mongodb: 27017
3435
};

0 commit comments

Comments
 (0)