fix(sundb): bundle the vendor JDBC driver so SunDB works out of the box
This commit is contained in:
19 files changed
+81
-5
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { SUNDB_DEFAULT_JDBC_DRIVER_CLASS, sundbJdbcDriverClass } from "@/lib/database/sundbDriverOptions";
|
||||
|
||||
describe("sundb driver options", () => {
|
||||
it("defaults the driver class to the vendor class bundled inside the Agent", () => {
|
||||
expect(SUNDB_DEFAULT_JDBC_DRIVER_CLASS).toBe("csii.sundb.jdbc.SundbDriver");
|
||||
expect(sundbJdbcDriverClass({})).toBe("csii.sundb.jdbc.SundbDriver");
|
||||
expect(sundbJdbcDriverClass({ jdbc_driver_class: " " })).toBe("csii.sundb.jdbc.SundbDriver");
|
||||
});
|
||||
|
||||
it("keeps an explicit driver class", () => {
|
||||
expect(sundbJdbcDriverClass({ jdbc_driver_class: " com.example.SundbDriver " })).toBe("com.example.SundbDriver");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { ConnectionConfig } from "@/types/database";
|
||||
|
||||
/**
|
||||
* The SunDB (科蓝 SUNDB) Agent bundles the vendor JDBC driver (vendored under
|
||||
* `agents/drivers/sundb/libs/`), so an empty `jdbc_driver_paths` resolves the
|
||||
* driver class on the Agent's own classpath. Callers may still point a
|
||||
* connection at a newer vendor JAR, which the Agent then loads in an isolated
|
||||
* URLClassLoader instead.
|
||||
*/
|
||||
export const SUNDB_DEFAULT_JDBC_DRIVER_CLASS = "csii.sundb.jdbc.SundbDriver";
|
||||
|
||||
type SundbDriverConfig = Partial<Pick<ConnectionConfig, "jdbc_driver_class">>;
|
||||
|
||||
export function sundbJdbcDriverClass(config: SundbDriverConfig): string {
|
||||
return config.jdbc_driver_class?.trim() || SUNDB_DEFAULT_JDBC_DRIVER_CLASS;
|
||||
}
|
||||
Reference in new issue
Block a user