fix(xugu): accept scheduler job object sources

This commit is contained in:
Elias authored and GitHub committed 2026-09-03 01:53:54 +08:00
1 parent d6fc1fe52c
commit 1818387da5
4 files changed
+27

No files matched your search

+4
View File
@@ -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));
+13
View File
@@ -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]
+1
View File
@@ -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
+9
View File
@@ -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 [