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(xugu): accept scheduler job object sources

Elias1818387da54e
diff --git a/crates/dbx-core/src/object_source_sql.rs b/crates/dbx-core/src/object_source_sql.rs
index 3fc052b957..1f2a464559 100644
--- a/crates/dbx-core/src/object_source_sql.rs
+++ b/crates/dbx-core/src/object_source_sql.rs
@@ -350,6 +350,7 @@ fn object_type_keyword(object_type: &ObjectSourceKind) -> &'static str {
ObjectSourceKind::Event => "EVENT",
ObjectSourceKind::Sequence => "SEQUENCE",
ObjectSourceKind::Synonym => "SYNONYM",
+ ObjectSourceKind::Job => "JOB",
ObjectSourceKind::Package => "PACKAGE",
ObjectSourceKind::PackageBody => "PACKAGE BODY",
ObjectSourceKind::Type => "TYPE",
@@ -947,6 +948,8 @@ fn parse_object_source_kind(value: &str) -> Option<ObjectSourceKind> {
Some(ObjectSourceKind::Sequence)
} else if value.eq_ignore_ascii_case("SYNONYM") {
Some(ObjectSourceKind::Synonym)
+ } else if value.eq_ignore_ascii_case("JOB") {
+ Some(ObjectSourceKind::Job)
} else if value.eq_ignore_ascii_case("PACKAGE") {
Some(ObjectSourceKind::Package)
} else if value.eq_ignore_ascii_case("PACKAGE BODY") || value.eq_ignore_ascii_case("PACKAGE_BODY") {
@@ -1736,6 +1739,7 @@ mod tests {
fn parses_programmable_metadata_object_kinds() {
assert_eq!(parse_object_source_kind("TRIGGER"), Some(ObjectSourceKind::Trigger));
assert_eq!(parse_object_source_kind("SYNONYM"), Some(ObjectSourceKind::Synonym));
+ assert_eq!(parse_object_source_kind("JOB"), Some(ObjectSourceKind::Job));
assert_eq!(parse_object_source_kind("TYPE"), Some(ObjectSourceKind::Type));
assert_eq!(parse_object_source_kind("TYPE_BODY"), Some(ObjectSourceKind::TypeBody));
assert_eq!(parse_object_source_kind("PACKAGE BODY"), Some(ObjectSourceKind::PackageBody));
diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs
index f1820d2ccd..2e2764ba11 100644
--- a/crates/dbx-core/src/schema.rs
+++ b/crates/dbx-core/src/schema.rs
@@ -8117,6 +8117,7 @@ fn sqlite_object_type(kind: &db::ObjectSourceKind) -> &'static str {
| db::ObjectSourceKind::Event
| db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
+ | db::ObjectSourceKind::Job
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -8133,6 +8134,7 @@ fn sqlserver_object_type_filter(kind: &db::ObjectSourceKind) -> &'static str {
db::ObjectSourceKind::Event
| db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
+ | db::ObjectSourceKind::Job
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -8378,6 +8380,7 @@ fn postgres_object_source_sql_inner(
db::ObjectSourceKind::Trigger
| db::ObjectSourceKind::Event
| db::ObjectSourceKind::Synonym
+ | db::ObjectSourceKind::Job
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -8386,6 +8389,12 @@ fn postgres_object_source_sql_inner(
}
pub fn oracle_object_source_sql(schema: &str, name: &str, kind: &db::ObjectSourceKind) -> String {
+ // Scheduler jobs are currently an Xugu-specific Agent object. Do not
+ // manufacture an Oracle DBMS_METADATA request for a kind Oracle does not
+ // expose through this generic source-SQL helper.
+ if matches!(kind, db::ObjectSourceKind::Job) {
+ return String::new();
+ }
let object_type = match kind {
db::ObjectSourceKind::View => "VIEW",
db::ObjectSourceKind::MaterializedView => "MATERIALIZED_VIEW",
@@ -8395,6 +8404,7 @@ pub fn oracle_object_source_sql(schema: &str, name: &str, kind: &db::ObjectSourc
db::ObjectSourceKind::Event => "EVENT",
db::ObjectSourceKind::Sequence => "SEQUENCE",
db::ObjectSourceKind::Synonym => "SYNONYM",
+ db::ObjectSourceKind::Job => "",
db::ObjectSourceKind::Package => "PACKAGE",
db::ObjectSourceKind::PackageBody => "PACKAGE_BODY",
db::ObjectSourceKind::Type => "TYPE",
@@ -8452,6 +8462,7 @@ pub fn mysql_object_source_sql(database: &str, name: &str, kind: &db::ObjectSour
db::ObjectSourceKind::Event => format!("SHOW CREATE EVENT {qualified_name}"),
db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
+ | db::ObjectSourceKind::Job
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -8488,6 +8499,7 @@ pub(crate) fn mysql_object_source_ddl_column_index(kind: &db::ObjectSourceKind)
| db::ObjectSourceKind::Trigger
| db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
+ | db::ObjectSourceKind::Job
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -9706,6 +9718,7 @@ mod object_source_tests {
oracle_object_source_sql("HR", "ORDER_SEQ", &ObjectSourceKind::Sequence),
"SELECT DBMS_METADATA.GET_DDL('SEQUENCE', 'ORDER_SEQ', 'HR') FROM DUAL"
);
+ assert_eq!(oracle_object_source_sql("HR", "NIGHTLY_JOB", &ObjectSourceKind::Job), "");
}
#[test]
diff --git a/crates/dbx-core/src/transfer.rs b/crates/dbx-core/src/transfer.rs
index 9b0e48b980..89b7287aba 100644
--- a/crates/dbx-core/src/transfer.rs
+++ b/crates/dbx-core/src/transfer.rs
@@ -8234,6 +8234,7 @@ where
}
db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
+ | db::ObjectSourceKind::Job
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody => object.source.clone(),
db::ObjectSourceKind::Trigger
diff --git a/crates/dbx-core/src/types.rs b/crates/dbx-core/src/types.rs
index daf1f9d45a..c2a713caab 100644
--- a/crates/dbx-core/src/types.rs
+++ b/crates/dbx-core/src/types.rs
@@ -158,6 +158,7 @@ pub enum ObjectSourceKind {
Event,
Sequence,
Synonym,
+ Job,
Package,
PackageBody,
Type,
@@ -850,6 +851,14 @@ mod tests {
assert_eq!(serde_json::to_string(&kind).unwrap(), "\"SYNONYM\"");
}
+ #[test]
+ fn object_source_kind_accepts_job_wire_value() {
+ let kind: ObjectSourceKind = serde_json::from_str("\"JOB\"").unwrap();
+
+ assert_eq!(kind, ObjectSourceKind::Job);
+ assert_eq!(serde_json::to_string(&kind).unwrap(), "\"JOB\"");
+ }
+
#[test]
fn completion_candidate_kind_accepts_uppercase_agent_wire_values() {
for (wire_value, expected) in [