fix(sql): correct table introducer keyword completion
This commit is contained in:
1 parent
9e17d465a0
commit
8a3b8eed67
2 files changed
+28
-6
No files matched your search
@@ -205,6 +205,24 @@ describe("semantic SQL completion candidates", () => {
|
||||
expect(items).toEqual(expect.arrayContaining([expect.objectContaining({ label: expectedKeyword, type: "keyword" })]));
|
||||
});
|
||||
|
||||
it.each([
|
||||
["UPDATE", "update|", "sqlserver"],
|
||||
["FROM", "select * from|", "mysql"],
|
||||
["JOIN", "select * from t1 join|", "mysql"],
|
||||
] as const)("keeps a fully typed table introducer keyword (%s) in the candidate list", (keyword, sql, databaseType) => {
|
||||
const { context, items } = semanticCompletion(sql, {}, { databaseType });
|
||||
|
||||
expect(context.suggestKeywords).toBe(true);
|
||||
expect(items).toEqual(expect.arrayContaining([expect.objectContaining({ label: keyword, type: "keyword" })]));
|
||||
});
|
||||
|
||||
it("offers tables once a table introducer keyword is committed with whitespace", () => {
|
||||
const { context, items } = semanticCompletion("update |", { tables: [{ name: "orders" }] }, { databaseType: "sqlserver" });
|
||||
|
||||
expect(context.exclusiveTableSuggestions).toBe(true);
|
||||
expect(items).toEqual(expect.arrayContaining([expect.objectContaining({ label: "orders", type: "table" })]));
|
||||
});
|
||||
|
||||
it("does not offer keyword continuations for qualified column prefixes", () => {
|
||||
const columnsByTable = new Map<string, SqlCompletionColumn[]>([["t", [{ name: "order_number", table: "t" }]]]);
|
||||
const { context, items } = semanticCompletion("SELECT * FROM t WHERE t.or|", { columnsByTable }, { databaseType: "mysql", dialect: "mysql" });
|
||||
|
||||
Reference in new issue
Block a user