fix(sql): add missing T-SQL keywords to sqlserver completion

This commit is contained in:
zipg authored and GitHub committed 2026-09-21 01:33:57 +08:00
1 parent 510fac6665
commit 221683950d
3 files changed
+91

No files matched your search

@@ -0,0 +1,24 @@
import { describe, expect, it } from "vitest";
import { buildSqlCompletionItems } from "@/lib/sql/sqlCompletion";
describe("SQL Server T-SQL keyword completion", () => {
function labelsFor(prefix: string): string[] {
return buildSqlCompletionItems(prefix, prefix.length, {
databaseType: "sqlserver",
tables: [],
columnsByTable: new Map(),
}).map((item) => item.label);
}
it("offers DECLARE ahead of DECIMAL for the decl prefix (issue #9319)", () => {
const labels = labelsFor("decl");
expect(labels).toContain("DECLARE");
expect(labels).toContain("DECIMAL");
expect(labels.indexOf("DECLARE")).toBeLessThan(labels.indexOf("DECIMAL"));
});
it.each(["declare", "exec", "print", "raiserror", "waitfor", "throw", "isnull", "getdate", "newid", "scope_identity", "error_message"])("offers %s for a SQL Server batch", (keyword) => {
expect(labelsFor(keyword.slice(0, -1))).toContain(keyword.toUpperCase());
});
});