fix(sql): add sql server completions

This commit is contained in:
t8y2
2026-05-13 17:11:33 +08:00
parent 02b257dd0f
commit 80f33b1460
2 changed files with 68 additions and 0 deletions
+36
View File
@@ -123,6 +123,42 @@ test("always includes keywords alongside table suggestions", () => {
assert.ok(items.some((item) => item.type === "keyword" && item.label === "USING"));
});
test("suggests SQL Server IF keyword for conditional DDL", () => {
const sql = "DROP TABLE I";
const items = buildSqlCompletionItems(sql, sql.length, {
tables,
columnsByTable,
});
assert.ok(items.some((item) => item.type === "keyword" && item.label === "IF"));
});
test("suggests SQL Server IIF and CHOOSE scalar functions", () => {
const iifItems = buildSqlCompletionItems("SELECT II", "SELECT II".length, {
tables,
columnsByTable,
});
const chooseItems = buildSqlCompletionItems("SELECT CHO", "SELECT CHO".length, {
tables,
columnsByTable,
});
assert.ok(iifItems.some((item) => item.type === "keyword" && item.label === "IIF"));
assert.ok(chooseItems.some((item) => item.type === "keyword" && item.label === "CHOOSE"));
});
test("suggests SQL Server data types in CREATE TABLE column definitions", () => {
const sql = "CREATE TABLE dbo.jobs (id ";
const items = buildSqlCompletionItems(sql, sql.length, {
tables,
columnsByTable,
});
assert.ok(items.some((item) => item.type === "keyword" && item.label === "INT"));
assert.ok(items.some((item) => item.type === "keyword" && item.label === "BIGINT"));
assert.ok(items.some((item) => item.type === "keyword" && item.label === "NVARCHAR"));
});
test("limits table suggestions for large schemas after filtering by prefix", () => {
const largeTables: SqlCompletionTable[] = Array.from({ length: 500 }, (_, index) => ({
name: `erp_invoice_${String(index).padStart(4, "0")}`,