fix(postgres): support quoted schema autocomplete
This commit is contained in:
1 parent
af40af603e
commit
0f40f6cd0c
2 files changed
+111
-7
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildSqlCompletionItems, getSqlCompletionContext } from "@/lib/sqlCompletion";
|
||||
|
||||
describe("sqlCompletion quoted schema qualifiers", () => {
|
||||
it("parses quoted PostgreSQL schema names before a dot", () => {
|
||||
const sql = 'SELECT *\nFROM "order-management".';
|
||||
const context = getSqlCompletionContext(sql, sql.length);
|
||||
|
||||
expect(context.qualifier).toBe("order-management");
|
||||
expect(context.prefix).toBe("");
|
||||
expect(context.suggestTables).toBe(true);
|
||||
expect(context.exclusiveColumnSuggestions).toBe(false);
|
||||
});
|
||||
|
||||
it("suggests tables after a quoted schema qualifier", () => {
|
||||
const sql = 'SELECT *\nFROM "order-management".';
|
||||
const items = buildSqlCompletionItems(sql, sql.length, {
|
||||
dialect: "postgres",
|
||||
tables: [
|
||||
{ name: "orders", schema: "order-management", type: "table" },
|
||||
{ name: "shipments", schema: "order-management", type: "table" },
|
||||
],
|
||||
columnsByTable: new Map(),
|
||||
});
|
||||
|
||||
expect(items.some((item) => item.label === "orders" && item.type === "table")).toBe(true);
|
||||
expect(items.some((item) => item.label === "shipments" && item.type === "table")).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user