fix(xugu): support synonym object source requests

This commit is contained in:
Elias authored and GitHub committed 2026-07-30 18:18:43 +08:00
1 parent 7d1a72e074
commit 44f49253d7
6 files changed
+28 -4

No files matched your search

+4
View File
@@ -327,6 +327,7 @@ fn object_type_keyword(object_type: &ObjectSourceKind) -> &'static str {
ObjectSourceKind::Function => "FUNCTION",
ObjectSourceKind::Trigger => "TRIGGER",
ObjectSourceKind::Sequence => "SEQUENCE",
ObjectSourceKind::Synonym => "SYNONYM",
ObjectSourceKind::Package => "PACKAGE",
ObjectSourceKind::PackageBody => "PACKAGE BODY",
ObjectSourceKind::Type => "TYPE",
@@ -894,6 +895,8 @@ fn parse_object_source_kind(value: &str) -> Option<ObjectSourceKind> {
Some(ObjectSourceKind::Trigger)
} else if value.eq_ignore_ascii_case("SEQUENCE") {
Some(ObjectSourceKind::Sequence)
} else if value.eq_ignore_ascii_case("SYNONYM") {
Some(ObjectSourceKind::Synonym)
} 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") {
@@ -1535,6 +1538,7 @@ mod tests {
#[test]
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("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));
+6
View File
@@ -5285,6 +5285,7 @@ fn sqlite_object_type(kind: &db::ObjectSourceKind) -> &'static str {
| db::ObjectSourceKind::Function
| db::ObjectSourceKind::Trigger
| db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -5299,6 +5300,7 @@ fn sqlserver_object_type_filter(kind: &db::ObjectSourceKind) -> &'static str {
db::ObjectSourceKind::Function => "'FN','IF','TF','FS','FT'",
db::ObjectSourceKind::Trigger => "'TR'",
db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -5535,6 +5537,7 @@ fn postgres_object_source_sql_inner(
)
}
db::ObjectSourceKind::Trigger
| db::ObjectSourceKind::Synonym
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -5550,6 +5553,7 @@ pub fn oracle_object_source_sql(schema: &str, name: &str, kind: &db::ObjectSourc
db::ObjectSourceKind::Function => "FUNCTION",
db::ObjectSourceKind::Trigger => "TRIGGER",
db::ObjectSourceKind::Sequence => "SEQUENCE",
db::ObjectSourceKind::Synonym => "SYNONYM",
db::ObjectSourceKind::Package => "PACKAGE",
db::ObjectSourceKind::PackageBody => "PACKAGE_BODY",
db::ObjectSourceKind::Type => "TYPE",
@@ -5605,6 +5609,7 @@ pub fn mysql_object_source_sql(database: &str, name: &str, kind: &db::ObjectSour
db::ObjectSourceKind::Function => format!("SHOW CREATE FUNCTION {qualified_name}"),
db::ObjectSourceKind::Trigger
| db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
@@ -5638,6 +5643,7 @@ pub(crate) fn mysql_object_source_ddl_column_index(kind: &db::ObjectSourceKind)
| db::ObjectSourceKind::Function
| db::ObjectSourceKind::Trigger
| db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
| db::ObjectSourceKind::Type
+4 -3
View File
@@ -4979,9 +4979,10 @@ where
rewrite_postgres_routine_schema(&object.source, &request.source_schema, &request.target_schema)
.unwrap_or_else(|| object.source.clone())
}
db::ObjectSourceKind::Sequence | db::ObjectSourceKind::Package | db::ObjectSourceKind::PackageBody => {
object.source.clone()
}
db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody => object.source.clone(),
db::ObjectSourceKind::Trigger | db::ObjectSourceKind::Type | db::ObjectSourceKind::TypeBody => {
object.source.clone()
}
+10 -1
View File
@@ -103,6 +103,7 @@ pub enum ObjectSourceKind {
Function,
Trigger,
Sequence,
Synonym,
Package,
PackageBody,
Type,
@@ -383,7 +384,7 @@ pub struct OwnerInfo {
#[cfg(test)]
mod tests {
use super::ObjectInfo;
use super::{ObjectInfo, ObjectSourceKind};
#[test]
fn list_objects_payload_preserves_optional_validity() {
@@ -394,4 +395,12 @@ mod tests {
assert_eq!(objects[0].valid, Some(false));
assert_eq!(objects[0].object_type, "TRIGGER");
}
#[test]
fn object_source_kind_accepts_synonym_wire_value() {
let kind: ObjectSourceKind = serde_json::from_str("\"SYNONYM\"").unwrap();
assert_eq!(kind, ObjectSourceKind::Synonym);
assert_eq!(serde_json::to_string(&kind).unwrap(), "\"SYNONYM\"");
}
}