use super::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum IndexKind {
Range,
Point,
Text,
Fulltext,
Lookup,
Vector,
}
impl IndexKind {
pub fn storage_tag(&self) -> &'static str {
match self {
IndexKind::Range => "range",
IndexKind::Point => "point",
IndexKind::Text => "text",
IndexKind::Fulltext => "fulltext",
IndexKind::Lookup => "lookup",
IndexKind::Vector => "vector",
}
}
pub fn display_name(&self) -> &'static str {
match self {
IndexKind::Range => "RANGE",
IndexKind::Point => "POINT",
IndexKind::Text => "TEXT",
IndexKind::Fulltext => "FULLTEXT",
IndexKind::Lookup => "LOOKUP",
IndexKind::Vector => "VECTOR",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SchemaEntityType {
Node,
Relationship,
}
impl SchemaEntityType {
pub fn as_str(&self) -> &'static str {
match self {
SchemaEntityType::Node => "NODE",
SchemaEntityType::Relationship => "RELATIONSHIP",
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum SchemaName {
Literal(String),
Parameter(String),
}
#[derive(Debug, Clone, PartialEq)]
pub enum OptionsForm {
Absent,
Literal(Vec<(String, Expr)>),
Parameter(String),
}
impl OptionsForm {
pub fn literal(&self) -> Option<&[(String, Expr)]> {
match self {
Self::Literal(entries) => Some(entries),
Self::Absent | Self::Parameter(_) => None,
}
}
pub fn parameter(&self) -> Option<&str> {
match self {
Self::Parameter(name) => Some(name),
Self::Absent | Self::Literal(_) => None,
}
}
pub fn literal_mut(&mut self) -> Option<&mut [(String, Expr)]> {
match self {
Self::Literal(entries) => Some(entries),
Self::Absent | Self::Parameter(_) => None,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CreateIndexClause {
pub name: Option<SchemaName>,
pub entity_type: SchemaEntityType,
pub labels: Vec<SmallName>,
pub properties: Vec<SmallName>,
pub if_not_exists: bool,
pub kind: IndexKind,
pub on_each: bool,
pub with_properties: Vec<SmallName>,
pub options: OptionsForm,
}
#[derive(Debug, Clone, PartialEq)]
pub struct DropIndexClause {
pub name: SchemaName,
pub if_exists: bool,
pub legacy_target: Option<(SmallName, SmallName)>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct CreateConstraintClause {
pub name: Option<SchemaName>,
pub entity_type: SchemaEntityType,
pub label: SmallName,
pub variable: SmallName,
pub properties: Vec<SmallName>,
pub constraint_type: String, pub if_not_exists: bool,
pub property_type: Option<TypeExpr>,
pub options: OptionsForm,
pub enforced_label: Option<SmallName>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct DropConstraintClause {
pub name: SchemaName,
pub if_exists: bool,
}