Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(oracle): refresh schema cache and complete table lists

t8y261bd7480f4d5
diff --git a/Cargo.lock b/Cargo.lock
index c2550a3365..4d2687bf28 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1879,7 +1879,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -2213,7 +2213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -3211,7 +3211,7 @@ dependencies = [
"js-sys",
"log",
"wasm-bindgen",
- "windows-core 0.61.2",
+ "windows-core 0.62.2",
]
[[package]]
@@ -4195,7 +4195,7 @@ dependencies = [
"png 0.18.1",
"serde",
"thiserror 2.0.18",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -4286,7 +4286,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -5657,7 +5657,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
- "windows-sys 0.59.0",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -6234,7 +6234,7 @@ dependencies = [
[[package]]
name = "rust-oracle"
version = "0.1.6"
-source = "git+https://github.com/t8y2/rust-oracle?branch=main#5620073f31adda95b9781d175a77d535b9c198ed"
+source = "git+https://github.com/t8y2/rust-oracle?branch=main#71795c0f5e3c20e0ba033bf26dd082a036405953"
dependencies = [
"aes 0.8.4",
"async-trait",
@@ -6349,7 +6349,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.12.1",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -6450,7 +6450,7 @@ dependencies = [
"security-framework 3.7.0",
"security-framework-sys",
"webpki-root-certs",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -7102,7 +7102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
dependencies = [
"libc",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -8042,7 +8042,7 @@ dependencies = [
"getrandom 0.4.2",
"once_cell",
"rustix 1.1.4",
- "windows-sys 0.59.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -8541,7 +8541,7 @@ dependencies = [
"png 0.18.1",
"serde",
"thiserror 2.0.18",
- "windows-sys 0.60.2",
+ "windows-sys 0.61.2",
]
[[package]]
diff --git a/crates/dbx-core/src/db/oracle_driver.rs b/crates/dbx-core/src/db/oracle_driver.rs
index 9dd0135d2e..6fdd58ed6f 100644
--- a/crates/dbx-core/src/db/oracle_driver.rs
+++ b/crates/dbx-core/src/db/oracle_driver.rs
@@ -59,20 +59,33 @@ fn value_to_json(val: &rust_oracle::Value) -> serde_json::Value {
pub async fn list_databases(conn: &OracleClient) -> Result<Vec<DatabaseInfo>, String> {
let result = conn
.query(
- "SELECT username FROM all_users \
- WHERE username NOT IN (\
- 'SYS','SYSTEM','SYSMAN','DBSNMP','SYSBACKUP','SYSDG','SYSKM','OUTLN',\
- 'AUDSYS','LBACSYS','DVF','DVSYS','APPQOSSYS','CTXSYS','MDSYS','MDDATA',\
- 'ORDSYS','ORDDATA','ORDPLUGINS','XDB','ANONYMOUS','DIP','EXFSYS',\
- 'GSMADMIN_INTERNAL','GSMCATUSER','GSMUSER','OJVMSYS','OLAPSYS',\
- 'ORACLE_OCM','SI_INFORMTN_SCHEMA','WMSYS','XS$NULL','DBSFWUSER',\
- 'REMOTE_SCHEDULER_AGENT','PDBADMIN','DGPDB_INT','OPS$ORACLE',\
- 'GGSYS','FLOWS_FILES','APEX_PUBLIC_USER'\
+ "WITH schema_names AS ( \
+ SELECT SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') AS owner FROM DUAL \
+ UNION \
+ SELECT DISTINCT owner \
+ FROM all_objects \
+ WHERE object_type IN ('TABLE', 'VIEW') \
) \
- AND username NOT LIKE 'APEX_%' \
- AND username NOT LIKE 'FLOWS_%' \
- AND username NOT LIKE '%$%' \
- ORDER BY username",
+ SELECT owner \
+ FROM schema_names \
+ WHERE owner IS NOT NULL \
+ AND owner NOT IN (\
+ 'SYS','SYSTEM','SYSMAN','DBSNMP','SYSBACKUP','SYSDG','SYSKM','OUTLN',\
+ 'AUDSYS','LBACSYS','DVF','DVSYS','APPQOSSYS','CTXSYS','MDSYS','MDDATA',\
+ 'ORDSYS','ORDDATA','ORDPLUGINS','XDB','ANONYMOUS','DIP','EXFSYS',\
+ 'GSMADMIN_INTERNAL','GSMCATUSER','GSMUSER','OJVMSYS','OLAPSYS',\
+ 'ORACLE_OCM','SI_INFORMTN_SCHEMA','WMSYS','XS$NULL','DBSFWUSER',\
+ 'REMOTE_SCHEDULER_AGENT','PDBADMIN','DGPDB_INT','OPS$ORACLE',\
+ 'GGSYS','FLOWS_FILES','APEX_PUBLIC_USER'\
+ ) \
+ AND owner NOT LIKE 'APEX_%' \
+ AND owner NOT LIKE 'FLOWS_%' \
+ AND owner NOT LIKE '%$%' \
+ ORDER BY CASE \
+ WHEN owner = SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') THEN 0 \
+ WHEN owner = SYS_CONTEXT('USERENV', 'SESSION_USER') THEN 1 \
+ ELSE 2 \
+ END, owner",
&[],
)
.await
diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.ts
index a4969abd12..fc6d9853a1 100644
--- a/src/stores/connectionStore.ts
+++ b/src/stores/connectionStore.ts
@@ -322,9 +322,29 @@ export const useConnectionStore = defineStore("connection", () => {
loadedTreeNodeChildrenIds.value.delete(id);
}
}
+ api.deleteSchemaCachePrefix(`${prefix}:`).catch(() => undefined);
api.deleteSchemaCachePrefix(`${schemaCacheKey(prefix)}:`).catch(() => undefined);
}
+ function schemaCachePrefixForNode(node: TreeNode): string | null {
+ if (node.type === "connection" && node.connectionId) {
+ return `${schemaCacheKey(node.connectionId)}:`;
+ }
+ if (node.type === "database" && node.connectionId && node.database) {
+ return `${schemaCacheKey(node.connectionId, node.database)}:`;
+ }
+ if (node.type === "schema" && node.connectionId && node.database && node.schema) {
+ return `${schemaCacheKey(node.connectionId, node.database, node.schema)}:`;
+ }
+ return null;
+ }
+
+ async function clearPersistedTreeCacheForNode(node: TreeNode) {
+ const prefix = schemaCachePrefixForNode(node);
+ if (!prefix) return;
+ await api.deleteSchemaCachePrefix(prefix).catch(() => undefined);
+ }
+
function findParentNode(nodes: TreeNode[], id: string, parent: TreeNode | null = null): TreeNode | null {
for (const node of nodes) {
if (node.id === id) return parent;
@@ -948,6 +968,8 @@ export const useConnectionStore = defineStore("connection", () => {
async function refreshTreeNode(node: TreeNode) {
const expandedIds = collectExpandedNodeIds([node]);
expandedIds.add(node.id);
+ await clearPersistedTreeCacheForNode(node);
+ clearLoadedChildrenCache(node.id);
if (node.type !== "connection-group") {
node.children = [];
}