fix(doris): complete external catalog suggestions
This commit is contained in:
11 files changed
+254
-81
No files matched your search
@@ -50,4 +50,11 @@ describe("openTabsPersistence originalSql round-trip", () => {
|
||||
expect(restored.sql).toBe("SELECT 1");
|
||||
expect(restored.originalSql).toBe("");
|
||||
});
|
||||
|
||||
it("preserves an external Doris catalog across tab restore", () => {
|
||||
const [restored] = roundTrip([queryTab({ database: "dbx_catalog_completion", catalog: "dbx_mysql_catalog" })]);
|
||||
|
||||
expect(restored.database).toBe("dbx_catalog_completion");
|
||||
expect(restored.catalog).toBe("dbx_mysql_catalog");
|
||||
});
|
||||
});
|
||||
@@ -77,4 +77,27 @@ describe("completionTreeIndex", () => {
|
||||
expect(completionTablesFromTree(tree, "conn", "hive", "sales_analytics")).toEqual(expected);
|
||||
expect(completionTablesFromTree(tree, "conn", "hive")).toEqual(expected);
|
||||
});
|
||||
|
||||
it("isolates Doris internal and external catalog tables with the same database name", () => {
|
||||
const tree: TreeNode[] = [
|
||||
{
|
||||
id: "internal-orders",
|
||||
label: "orders",
|
||||
type: "table",
|
||||
connectionId: "doris",
|
||||
database: "sales",
|
||||
},
|
||||
{
|
||||
id: "hive-orders",
|
||||
label: "orders",
|
||||
type: "table",
|
||||
connectionId: "doris",
|
||||
catalog: "hive_catalog",
|
||||
database: "sales",
|
||||
},
|
||||
];
|
||||
|
||||
expect(completionTablesFromTree(tree, "doris", "sales")).toEqual([{ name: "orders", schema: undefined, type: "table" }]);
|
||||
expect(completionTablesFromTree(tree, "doris", "sales", undefined, "hive_catalog")).toEqual([{ name: "orders", catalog: "hive_catalog", schema: undefined, type: "table" }]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const contentAreaSource = readFileSync(new URL("../../../components/layout/ContentArea.vue", import.meta.url), "utf8");
|
||||
const queryEditorSource = readFileSync(new URL("../../../components/editor/QueryEditor.vue", import.meta.url), "utf8");
|
||||
const sidebarRuntimeSource = readFileSync(new URL("../../../components/sidebar/SidebarTreeRuntimeHost.vue", import.meta.url), "utf8");
|
||||
const openTabsPersistenceSource = readFileSync(new URL("../../app/openTabsPersistence.ts", import.meta.url), "utf8");
|
||||
|
||||
describe("Doris external catalog completion wiring", () => {
|
||||
it("preserves the selected catalog from the sidebar query action into QueryEditor", () => {
|
||||
expect(sidebarRuntimeSource).toContain('queryStore.createTab(node.connectionId, node.database, undefined, "query", node.schema, undefined, node.catalog)');
|
||||
expect(contentAreaSource).toContain(':catalog="activeTab.catalog"');
|
||||
expect(queryEditorSource).toContain("catalog?: string;");
|
||||
expect(openTabsPersistenceSource).toContain("catalog: tab.catalog");
|
||||
});
|
||||
|
||||
it("includes catalog scope in table and column completion requests", () => {
|
||||
expect(queryEditorSource).toMatch(/lookupLocalCompletionTables\([\s\S]*?props\.catalog/);
|
||||
expect(queryEditorSource).toMatch(/listCompletionTables\([\s\S]*?props\.catalog/);
|
||||
expect(queryEditorSource).toMatch(/listCompletionColumns\([\s\S]*?catalog\)/);
|
||||
expect(queryEditorSource).toMatch(/watch\(\s*\(\) => props\.catalog,[\s\S]*?refreshCompletionCache\(\)/);
|
||||
expect(queryEditorSource).toMatch(/function shouldLoadCompletionObjects[\s\S]*?if \(props\.catalog\) return false/);
|
||||
expect(queryEditorSource).toMatch(/if \(!props\.catalog && props\.databaseType !== "oracle"[\s\S]*?listCompletionObjects/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user