fix: allow default database for tree-schema databases

TREE_SCHEMA mode databases (saphana, jdbc, postgres, etc.) use an empty string to represent the default database selection. The previous check treated empty string as no database selected and incorrectly blocked query execution.
This commit is contained in:
gggaiitx authored and GitHub committed 2026-07-06 18:22:56 +08:00
1 parent 78019c44e2
commit 2fd2b0e770
2 files changed
+16 -2

No files matched your search

@@ -58,4 +58,16 @@ describe("requiresDatabaseSelection", () => {
it("still requires a database for ordinary MySQL queries", () => {
expect(requiresDatabaseSelection(queryTab(), connection("mysql"), "SELECT * FROM users")).toBe(true);
});
it("allows HANA with default database (empty string) to execute queries", () => {
expect(requiresDatabaseSelection(queryTab(""), connection("saphana"), "SELECT * FROM MOMX_MES.Z_SHIPMENT_INFORMATION")).toBe(false);
});
it("allows JDBC with default database (empty string) to execute queries", () => {
expect(requiresDatabaseSelection(queryTab(""), connection("jdbc"), "SELECT * FROM users")).toBe(false);
});
it("allows PostgreSQL with default database (empty string) to execute queries", () => {
expect(requiresDatabaseSelection(queryTab(""), connection("postgres"), "SELECT * FROM public.users")).toBe(false);
});
});