use std::any::{Any, TypeId};
pub struct DrainedChild {
pub parent_type_id: TypeId,
pub parent_entry_idx: usize,
pub child: Box<dyn Any + Send + Sync>,
pub child_type_id: TypeId,
pub fk_target_type_id: TypeId,
pub through_table: Option<String>,
pub through_parent_fk_col: Option<String>,
pub through_child_fk_col: Option<String>,
}
pub struct FixupLink {
pub parent_type_id: TypeId,
pub parent_entry_idx: usize,
pub child_type_id: TypeId,
pub child_entry_indices: Vec<usize>,
pub fk_target_type_id: TypeId,
pub through_table: Option<String>,
pub through_parent_fk_col: Option<String>,
pub through_child_fk_col: Option<String>,
}
pub fn m2m_insert_sql(
table: &str,
parent_col: &str,
child_col: &str,
row_count: usize,
) -> String {
let placeholders: Vec<String> = (0..row_count).map(|_| "(?, ?)".to_string()).collect();
format!(
"INSERT INTO {} ({}, {}) VALUES {}",
table,
parent_col,
child_col,
placeholders.join(", ")
)
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CascadeDeleteAction {
Delete,
SetNull,
}
pub struct CascadeDeleteDirective {
pub table: String,
pub fk_column: String,
pub principal_pk: i64,
pub action: CascadeDeleteAction,
}