feat(impala): add full database support

This commit is contained in:
zipg authored and GitHub committed 2026-08-14 20:41:57 +08:00
1 parent 185ff68d78
commit a6d9e6818e
54 files changed
+1092 -148

No files matched your search

@@ -130,6 +130,62 @@ describe("connectionStore save_password opt-out", () => {
expect(store.getConfig("pg-1")?.password).toBe("");
});
it("connects with an explicitly submitted empty password", async () => {
installApiMocks();
installPasswordPromptMock();
requestPassword.mockResolvedValue({ password: "", rememberPassword: false });
const { useConnectionStore } = await import("@/stores/connectionStore");
const store = useConnectionStore();
const connection = postgresConnection({ id: "pg-1", save_password: false, password: "" });
store.connections = [connection];
await store.connect(connection);
const { connectDb } = await import("@/lib/backend/api");
expect(connectDb).toHaveBeenCalledWith(expect.objectContaining({ id: "pg-1", password: "" }), expect.any(Number));
expect(store.getConfig("pg-1")).toEqual(expect.objectContaining({ password: "", save_password: false }));
});
it("connects to NOSASL Impala without prompting for an empty password", async () => {
installApiMocks();
installPasswordPromptMock();
const { useConnectionStore } = await import("@/stores/connectionStore");
const store = useConnectionStore();
const connection = postgresConnection({
id: "impala-1",
name: "Impala",
db_type: "impala",
port: 21050,
username: "",
password: "",
save_password: false,
url_params: "auth=noSasl",
});
store.connections = [connection];
await store.connect(connection);
expect(requestPassword).not.toHaveBeenCalled();
const { connectDb } = await import("@/lib/backend/api");
expect(connectDb).toHaveBeenCalledWith(expect.objectContaining({ id: "impala-1", password: "", save_password: false }), expect.any(Number));
});
it("remembers an explicitly submitted empty password", async () => {
installApiMocks();
installPasswordPromptMock();
requestPassword.mockResolvedValue({ password: "", rememberPassword: true });
const { useConnectionStore } = await import("@/stores/connectionStore");
const store = useConnectionStore();
const connection = postgresConnection({ id: "pg-1", save_password: false, password: "" });
store.connections = [connection];
await store.connect(connection);
const { saveConnections } = await import("@/lib/backend/api");
expect(saveConnections).toHaveBeenLastCalledWith(expect.arrayContaining([expect.objectContaining({ id: "pg-1", password: "", save_password: true })]));
expect(store.getConfig("pg-1")).toEqual(expect.objectContaining({ password: "", save_password: true }));
});
it("connect cancels when the prompt is dismissed", async () => {
installApiMocks();
installPasswordPromptMock();
+12 -18
View File
@@ -116,6 +116,7 @@ import { REDIS_SCAN_PAGE_SIZE_DEFAULT } from "@/lib/redis/redisKeyPattern";
import { normalizeRedisDatabaseAliases, redisDatabaseAlias, redisDatabaseLabel } from "@/lib/redis/redisDatabaseAlias";
import { appendAgentDriverUpdateHint, hasAgentDriverUpdate, hasInstalledAgentVersion, type AgentDriverInstallState } from "@/lib/connection/agentDriverInstallHint";
import { appendConnectionErrorHints, isMysqlMissingPasswordFailure } from "@/lib/connection/connectionErrorHints";
import { connectionNeedsPasswordPrompt } from "@/lib/connection/connectionPassword";
import { appendVisibleDatabaseSelection } from "@/lib/connection/connectionVisibleDatabases";
import { buildXuguTypeMemberNodes, isXuguTypeMemberContainer } from "@/lib/sidebar/xuguTypeMembers";
import { isXuguPublicSynonymScope, xuguSchemaDisplayName, XUGU_PUBLIC_SYNONYM_SCOPE } from "@/lib/sidebar/xuguPublicSynonyms";
@@ -1055,6 +1056,7 @@ export const useConnectionStore = defineStore("connection", () => {
trino: "Trino",
prestosql: "PrestoSQL",
hive: "Hive",
impala: "Apache Impala",
spark: "Apache Spark",
db2: "DB2",
informix: "Informix",
@@ -3084,12 +3086,12 @@ export const useConnectionStore = defineStore("connection", () => {
connectionId: config.id,
connectionName: config.name,
});
if (!result?.password) throw new Error(CONNECTION_PASSWORD_REQUIRED_MESSAGE);
if (!result) throw new Error(CONNECTION_PASSWORD_REQUIRED_MESSAGE);
return { config: { ...config, password: result.password }, rememberPassword: result.rememberPassword };
}
async function persistRememberedConnectionPassword(config: ConnectionConfig, rememberPassword: boolean, expectedConfigFingerprint: string): Promise<void> {
if (!rememberPassword || !config.password) return;
if (!rememberPassword) return;
const index = connections.value.findIndex((connection) => connection.id === config.id);
if (index < 0) return;
if (connectionConfigFingerprint(connections.value[index]) !== expectedConfigFingerprint) return;
@@ -3125,14 +3127,10 @@ export const useConnectionStore = defineStore("connection", () => {
const localAttempt = beginLocalConnectionAttempt(config.id);
try {
let rememberPassword = false;
if (config.save_password === false && !config.password) {
// 本次运行期已在会话凭据仓库暂存密码(save_password=false):免弹窗,
// 直接以空密码 connectDb,后端会从会话凭据仓库补主密码。
if (!(await hasSessionCredential(config.id))) {
const prompted = await ensureConnectionPassword(config);
config = prompted.config;
rememberPassword = prompted.rememberPassword;
}
if (connectionNeedsPasswordPrompt(config) && !(await hasSessionCredential(config.id))) {
const prompted = await ensureConnectionPassword(config);
config = prompted.config;
rememberPassword = prompted.rememberPassword;
}
await beforeConnectHandler?.(config);
if (config.db_type === "sqlserver") {
@@ -3340,14 +3338,10 @@ export const useConnectionStore = defineStore("connection", () => {
// Fast-path the common case (password saved or no password needed) so the
// in-flight dedup above keeps its exact microtask cadence; only await the
// interactive prompt when the connection actually needs a typed password.
if (config.save_password === false && !config.password) {
// 本次运行期已在会话凭据仓库暂存密码(save_password=false):免弹窗,
// 直接以空密码 connectDb,后端会从会话凭据仓库补主密码。
if (!(await hasSessionCredential(connectionId))) {
const prompted = await ensureConnectionPassword(config);
config = prompted.config;
rememberPassword = prompted.rememberPassword;
}
if (connectionNeedsPasswordPrompt(config) && !(await hasSessionCredential(connectionId))) {
const prompted = await ensureConnectionPassword(config);
config = prompted.config;
rememberPassword = prompted.rememberPassword;
}
await beforeConnectHandler?.(config);
if (config.db_type === "sqlserver") {