feat(dolt): add native profile, branch database discovery, and SQL completion

This commit is contained in:
hanxuanyu authored and GitHub committed 2026-08-10 00:37:34 +08:00
1 parent 56edbd3656
commit 681c6f35c5
19 files changed
+304 -23

No files matched your search

@@ -0,0 +1,24 @@
import { describe, expect, it } from "vitest";
import { buildSqlCompletionItems } from "@/lib/sql/sqlCompletion";
function completionLabels(sql: string, driverProfile: string): string[] {
return buildSqlCompletionItems(sql, sql.length, {
tables: [],
objects: [],
columnsByTable: new Map(),
databaseType: "mysql",
driverProfile,
}).map((item) => item.label);
}
describe("Dolt SQL completion", () => {
it("suggests Dolt routines for the Dolt profile", () => {
expect(completionLabels("DOLT_BR", "dolt")).toContain("DOLT_BRANCH");
expect(completionLabels("CALL DOLT_CH", "dolt")).toContain("DOLT_CHECKOUT");
});
it("does not expose Dolt routines to standard MySQL", () => {
expect(completionLabels("DOLT_BR", "mysql")).not.toContain("DOLT_BRANCH");
expect(completionLabels("CALL DOLT_CH", "mysql")).not.toContain("DOLT_CHECKOUT");
});
});
@@ -25,4 +25,14 @@ describe("ClickHouse signature help", () => {
expect(help?.overloads).toHaveLength(1);
expect(help?.overloads[0].parameterGroups).toEqual([["date", "INTERVAL expr unit"]]);
});
it("adds Dolt signature help only for the Dolt profile", () => {
const sql = "CALL DOLT_MERGE_BASE('main', ";
expect(getSqlFunctionSignatureHelp(sql, sql.length, "mysql", "mysql")).toBeNull();
const help = getSqlFunctionSignatureHelp(sql, sql.length, "mysql", "dolt");
expect(help?.name).toBe("DOLT_MERGE_BASE");
expect(help?.parameters).toEqual(["revision_a", "revision_b"]);
expect(help?.activeParameter).toBe(1);
});
});