use crate::query::expr::Expr;
use crate::value::Value;
#[derive(Debug, Clone, Default)]
pub enum OnConflict {
#[default]
None,
Update {
constraint: Vec<&'static str>,
updates: Vec<Assignment>,
},
DoNothing {
constraint: Vec<&'static str>,
},
}
#[derive(Debug, Clone)]
pub struct Assignment {
pub column: &'static str,
pub value: Expr,
}
impl Assignment {
pub fn new(column: &'static str, value: Expr) -> Self {
Self { column, value }
}
}
#[derive(Debug, Clone)]
pub struct InsertStatement {
pub table: &'static str,
pub columns: Vec<&'static str>,
pub rows: Vec<Vec<Value>>,
pub returning: Vec<&'static str>,
pub on_conflict: OnConflict,
}
#[derive(Debug, Clone)]
pub struct UpdateStatement {
pub table: &'static str,
pub assignments: Vec<Assignment>,
pub filters: Vec<Expr>,
pub returning: Vec<&'static str>,
}
#[derive(Debug, Clone)]
pub struct DeleteStatement {
pub table: &'static str,
pub filters: Vec<Expr>,
pub returning: Vec<&'static str>,
}