fix(editor): preserve view type in object navigation
This commit is contained in:
1 parent
39aa506e44
commit
69dd363417
8 files changed
+108
-25
No files matched your search
+23
-2
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { extractIdentifierAt, extractIdentifierDetailsAt, isSqlKeyword, matchTable, splitQualifiedIdentifier } from "@/lib/sql/sqlNavigation";
|
||||
import { extractIdentifierAt, extractIdentifierDetailsAt, isSqlKeyword, matchTable, splitQualifiedIdentifier, sqlObjectHoverDetail, sqlObjectNavigationTableType, sqlObjectNavigationTarget } from "@/lib/sql/sqlNavigation";
|
||||
|
||||
describe("extractIdentifierAt", () => {
|
||||
it("extracts unquoted qualified identifiers", () => {
|
||||
@@ -52,9 +52,10 @@ describe("splitQualifiedIdentifier", () => {
|
||||
|
||||
describe("matchTable", () => {
|
||||
it("matches schema-qualified table identifiers", () => {
|
||||
const table = { schema: "MAAC00", name: "Accounts" };
|
||||
const table = { schema: "MAAC00", name: "Accounts", type: "view" as const };
|
||||
|
||||
expect(matchTable("maac00.accounts", [table])).toBe(table);
|
||||
expect(matchTable("maac00.accounts", [table])?.type).toBe("view");
|
||||
});
|
||||
|
||||
it("matches catalog.schema.table identifiers against schema-scoped tables", () => {
|
||||
@@ -73,3 +74,23 @@ describe("matchTable", () => {
|
||||
expect(matchTable("u.users", [{ schema: "public", name: "users" }])).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("SQL object navigation metadata", () => {
|
||||
it("preserves view type and schema for command-click navigation", () => {
|
||||
expect(sqlObjectNavigationTarget({ name: "active_users", schema: "dbo", type: "view" })).toEqual({
|
||||
name: "active_users",
|
||||
schema: "dbo",
|
||||
type: "view",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the object type in hover details", () => {
|
||||
expect(sqlObjectHoverDetail({ name: "active_users", schema: "dbo", type: "view" })).toBe("view in dbo");
|
||||
expect(sqlObjectHoverDetail({ name: "users", schema: "dbo", type: "table" })).toBe("table in dbo");
|
||||
});
|
||||
|
||||
it("maps navigation types to table metadata types", () => {
|
||||
expect(sqlObjectNavigationTableType({ name: "active_users", type: "view" })).toBe("VIEW");
|
||||
expect(sqlObjectNavigationTableType({ name: "users", type: "table" })).toBe("TABLE");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user