Skip to content

Commit

Permalink
Merge pull request #2 from apecloud/feat/rdb_dcl
Browse files Browse the repository at this point in the history
feat: simple support for MySQL DCLs
  • Loading branch information
caiq1nyu authored Feb 14, 2025
2 parents c44f268 + ead61a1 commit cca6d4c
Show file tree
Hide file tree
Showing 30 changed files with 1,102 additions and 30 deletions.
1 change: 1 addition & 0 deletions dt-common/src/config/filter_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub struct FilterConfig {
pub do_events: String,
pub do_structures: String,
pub do_ddls: String,
pub do_dcls: String,
pub ignore_cmds: String,
pub where_conditions: String,
}
1 change: 1 addition & 0 deletions dt-common/src/config/task_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ impl TaskConfig {
ignore_cols: loader.get_optional(FILTER, "ignore_cols"),
do_events: loader.get_optional(FILTER, "do_events"),
do_ddls: loader.get_optional(FILTER, "do_ddls"),
do_dcls: loader.get_optional(FILTER, "do_dcls"),
do_structures: loader.get_with_default(FILTER, "do_structures", ASTRISK.to_string()),
ignore_cmds: loader.get_optional(FILTER, "ignore_cmds"),
where_conditions: loader.get_optional(FILTER, "where_conditions"),
Expand Down
26 changes: 26 additions & 0 deletions dt-common/src/meta/dcl_meta/dcl_data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use serde::{Deserialize, Serialize};
use serde_json::json;

use super::dcl_type::DclType;
use crate::config::config_enums::DbType;
use crate::meta::dcl_meta::dcl_statement::DclStatement;

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
pub struct DclData {
pub default_schema: String,
pub dcl_type: DclType,
pub db_type: DbType,
pub statement: DclStatement,
}

impl std::fmt::Display for DclData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", json!(self))
}
}

impl DclData {
pub fn to_sql(&self) -> String {
self.statement.to_sql(&self.db_type)
}
}
Loading

0 comments on commit cca6d4c

Please sign in to comment.