fix(transfer): show tables for supported database types

Refs: #6115
This commit is contained in:
t8y2 committed 2026-08-13 11:01:50 +00:00
1 parent f8b165fe20
commit 44cb278257
3 files changed
+39 -5

No files matched your search

@@ -1,5 +1,10 @@
import { describe, expect, it } from "vitest";
import { transferObjectFamily, transferObjectKindsForDatabase, isSameTransferFamily, crossFamilyTransferableKinds, TransferObjectFamily } from "@/lib/database/transferObjectKinds";
import { manifestDatabaseTypes } from "@/lib/database/databaseDriverManifest";
import { supportsTransfer } from "@/lib/database/databaseFeatureSupport";
import type { DatabaseType } from "@/types/database";
const TABLE_ONLY_TRANSFER_DATABASES: DatabaseType[] = ["sqlite", "rqlite", "cloudflare-d1", "duckdb", "clickhouse", "mongodb", "questdb", "hive", "spark"];
describe("transferObjectKinds", () => {
it("groups databases into transfer families", () => {
@@ -12,10 +17,22 @@ describe("transferObjectKinds", () => {
it("returns per-family object kinds", () => {
expect(transferObjectKindsForDatabase("mysql")).toEqual(["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "TRIGGER", "EVENT"]);
expect(transferObjectKindsForDatabase("postgres")).toContain("SEQUENCE");
expect(transferObjectKindsForDatabase("dameng")).toContain("TRIGGER");
expect(transferObjectKindsForDatabase("postgres")).toEqual(["TABLE", "VIEW", "MATERIALIZED_VIEW", "PROCEDURE", "FUNCTION", "TRIGGER", "SEQUENCE"]);
expect(transferObjectKindsForDatabase("oracle")).toEqual(["TABLE", "VIEW", "MATERIALIZED_VIEW", "PROCEDURE", "FUNCTION", "TRIGGER", "SEQUENCE"]);
expect(transferObjectKindsForDatabase("sqlserver")).toEqual(["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "TRIGGER", "SEQUENCE"]);
expect(transferObjectKindsForDatabase("sqlite")).toEqual([]);
});
it.each(TABLE_ONLY_TRANSFER_DATABASES)("falls back to tables for transfer-capable %s databases", (dbType) => {
expect(transferObjectKindsForDatabase(dbType)).toEqual(["TABLE"]);
});
it("covers every transfer-capable database outside the richer object families", () => {
expect(manifestDatabaseTypes().filter((dbType) => supportsTransfer(dbType) && !transferObjectFamily(dbType))).toEqual(TABLE_ONLY_TRANSFER_DATABASES);
});
it("does not expose objects for databases without transfer support", () => {
expect(transferObjectKindsForDatabase("redis")).toEqual([]);
expect(transferObjectKindsForDatabase(undefined)).toEqual([]);
});
it("detects same-family transfers", () => {
@@ -40,7 +57,7 @@ describe("transferObjectKinds", () => {
const same = crossFamilyTransferableKinds("mysql", "mysql");
expect(same).toContain("TRIGGER");
expect(same).toContain("EVENT");
// unsupported db
// transfer-capable database without a modeled cross-family executor
expect(crossFamilyTransferableKinds("sqlite", "mysql")).toEqual([]);
});
});
@@ -1,4 +1,5 @@
import type { DatabaseType } from "@/types/database";
import { supportsTransfer } from "@/lib/database/databaseFeatureSupport";
export enum TransferObjectFamily {
Mysql = "mysql",
@@ -48,7 +49,7 @@ export function transferObjectKindsForDatabase(dbType?: DatabaseType): TransferO
case TransferObjectFamily.SqlServer:
return [...SQLSERVER_KINDS];
default:
return [];
return supportsTransfer(dbType) ? ["TABLE"] : [];
}
}