use selene_core::DbString;
use crate::{
DeleteMode, EdgeDirection, LabelExpr, SourceSpan,
analyze::{BindingId, ElementKind},
};
use super::{BindingTableColumn, ProjectExpr};
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct InsertSiteId(u32);
impl InsertSiteId {
pub(crate) const fn new(raw: u32) -> Self {
Self(raw)
}
#[must_use]
pub const fn raw(self) -> u32 {
self.0
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum InsertEndpointRef {
Binding {
binding: BindingId,
column_index: u32,
},
InsertedNode(InsertSiteId),
}
#[derive(Clone, Debug, PartialEq)]
pub struct PropertyInit {
pub key: DbString,
pub value: ProjectExpr,
pub span: SourceSpan,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct DeleteTargetPlan {
pub target: BindingId,
pub element: ElementKind,
pub target_column_index: u32,
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum MutationOp {
InsertNode {
site_id: InsertSiteId,
binding: Option<BindingId>,
label_expr: Option<LabelExpr>,
property_inits: Vec<PropertyInit>,
output_column_index: Option<u32>,
output_column: Option<BindingTableColumn>,
span: SourceSpan,
},
InsertEdge {
site_id: InsertSiteId,
binding: Option<BindingId>,
label_expr: Option<LabelExpr>,
left: InsertEndpointRef,
right: InsertEndpointRef,
direction: EdgeDirection,
property_inits: Vec<PropertyInit>,
output_column_index: Option<u32>,
output_column: Option<BindingTableColumn>,
span: SourceSpan,
},
SetProperty {
target: BindingId,
element: ElementKind,
target_column_index: u32,
key: DbString,
value: ProjectExpr,
span: SourceSpan,
},
SetLabel {
target: BindingId,
element: ElementKind,
target_column_index: u32,
label: DbString,
span: SourceSpan,
},
RemoveProperty {
target: BindingId,
element: ElementKind,
target_column_index: u32,
key: DbString,
span: SourceSpan,
},
RemoveLabel {
target: BindingId,
element: ElementKind,
target_column_index: u32,
label: DbString,
span: SourceSpan,
},
DeleteTargets {
targets: Vec<DeleteTargetPlan>,
mode: DeleteMode,
span: SourceSpan,
},
}