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(mysql): restore trigger source lookup

t8y2ec8f308c53f1
diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs
index a2eef41c32..028559e7b7 100644
--- a/crates/dbx-core/src/schema.rs
+++ b/crates/dbx-core/src/schema.rs
@@ -2852,6 +2852,14 @@ mod tests {
);
}
+ #[test]
+ fn mysql_object_source_sql_emits_show_create_trigger() {
+ assert_eq!(
+ mysql_object_source_sql("tenant_db", "before_insert", &db::ObjectSourceKind::Trigger),
+ "SHOW CREATE TRIGGER `tenant_db`.`before_insert`"
+ );
+ }
+
#[test]
fn mysql_object_source_sql_emits_show_create_materialized_view() {
// Regression for the review comment: Doris / StarRocks ride on the MySQL
@@ -2879,6 +2887,7 @@ mod tests {
assert_eq!(mysql_object_source_ddl_column_index(&db::ObjectSourceKind::MaterializedView), 1);
assert_eq!(mysql_object_source_ddl_column_index(&db::ObjectSourceKind::Procedure), 2);
assert_eq!(mysql_object_source_ddl_column_index(&db::ObjectSourceKind::Function), 2);
+ assert_eq!(mysql_object_source_ddl_column_index(&db::ObjectSourceKind::Trigger), 2);
}
#[test]
@@ -6596,8 +6605,8 @@ pub fn mysql_object_source_sql(database: &str, name: &str, kind: &db::ObjectSour
db::ObjectSourceKind::View => format!("SHOW CREATE VIEW {qualified_name}"),
db::ObjectSourceKind::Procedure => format!("SHOW CREATE PROCEDURE {qualified_name}"),
db::ObjectSourceKind::Function => format!("SHOW CREATE FUNCTION {qualified_name}"),
- db::ObjectSourceKind::Trigger
- | db::ObjectSourceKind::Sequence
+ db::ObjectSourceKind::Trigger => format!("SHOW CREATE TRIGGER {qualified_name}"),
+ db::ObjectSourceKind::Sequence
| db::ObjectSourceKind::Synonym
| db::ObjectSourceKind::Package
| db::ObjectSourceKind::PackageBody
@@ -6621,7 +6630,7 @@ pub fn mysql_object_source_sql(database: &str, name: &str, kind: &db::ObjectSour
/// The shape of the result is dialect-dependent:
/// - `SHOW CREATE VIEW`, Doris/StarRocks `SHOW CREATE MATERIALIZED VIEW` →
/// `(Name, DDL)` → DDL at index `1`.
-/// - `SHOW CREATE PROCEDURE`, `SHOW CREATE FUNCTION` →
+/// - `SHOW CREATE PROCEDURE`, `SHOW CREATE FUNCTION`, `SHOW CREATE TRIGGER` →
/// `(Name, sql_mode, DDL, …)` → DDL at index `2`.
///
/// Encoded as a function so the index can be unit-tested without a live DB.