#[derive(Debug, Clone, Copy)]
pub struct ConstraintStatement<'a> {
pub relation: &'a str,
pub columns: &'a [String],
pub referential_action: bool,
}
impl<'a> ConstraintStatement<'a> {
pub const fn new(relation: &'a str, columns: &'a [String]) -> Self {
Self {
relation,
columns,
referential_action: false,
}
}
pub const fn referential_action(relation: &'a str, columns: &'a [String]) -> Self {
Self {
relation,
columns,
referential_action: true,
}
}
}
pub fn statement_relation(
context: super::ConstraintContext<'_>,
relation: &str,
) -> Result<String, uqa_sql::SQLError> {
Ok(context
.partitions
.catalog
.try_resolve_table_name(relation)
.map_err(|error| {
uqa_sql::SQLError::Internal(format!("resolve statement relation: {error}"))
})?
.unwrap_or_else(|| relation.to_string()))
}