use super::*;
#[derive(Debug, Clone, PartialEq)]
pub struct AlterDatabaseClause {
pub name: SchemaName,
pub if_exists: bool,
pub default_language: u32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct YieldItem {
pub name: SmallName,
pub alias: Option<SmallName>,
}
impl YieldItem {
pub fn effective_name(&self) -> SmallName {
self.alias.clone().unwrap_or_else(|| self.name.clone())
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct YieldList {
pub items: Vec<YieldItem>,
pub all: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum YieldMode {
Star,
Default,
Named,
}
impl YieldList {
pub fn mode(&self) -> YieldMode {
if self.all {
YieldMode::Star
} else if self.items.is_empty() {
YieldMode::Default
} else {
YieldMode::Named
}
}
pub fn present(&self) -> bool {
!matches!(self.mode(), YieldMode::Default)
}
pub fn names(&self) -> impl Iterator<Item = &SmallName> {
self.items.iter().map(|item| &item.name)
}
pub fn pairs(&self) -> impl Iterator<Item = (&SmallName, Option<&SmallName>, SmallName)> {
self.items
.iter()
.map(|item| (&item.name, item.alias.as_ref(), item.effective_name()))
}
pub fn effective_names(&self) -> impl Iterator<Item = SmallName> + '_ {
self.items.iter().map(YieldItem::effective_name)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowIndexesClause {
pub kind_filter: Option<IndexKind>,
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowFunctionsClause {
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
pub scope: FunctionScope,
pub executable: Option<ExecutableBy>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum ExecutableBy {
User(String),
Current,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum FunctionScope {
#[default]
All,
BuiltIn,
UserDefined,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowConstraintsClause {
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub type_filter: ConstraintTypeFilter,
pub stages: Vec<PageStage>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConstraintEntityFilter {
Any,
Node,
Relationship,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConstraintKindFilter {
Unique,
Key,
PropertyType,
Existence,
PropertyExistence,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ConstraintTypeFilter {
pub entity: ConstraintEntityFilter,
pub kind: Option<ConstraintKindFilter>,
}
impl ConstraintTypeFilter {
pub fn all() -> Self {
ConstraintTypeFilter {
entity: ConstraintEntityFilter::Any,
kind: None,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowDatabasesClause {
pub filter: DatabaseFilter,
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum DatabaseFilter {
All,
Default,
Home,
Named(SchemaName),
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowRolesClause {
pub modifier: RoleModifier,
pub with_users: bool,
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RoleModifier {
Any,
All,
Populated,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowServersClause {
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowUsersClause {
pub current_only: bool,
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowProceduresClause {
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
pub executable: Option<ExecutableBy>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowSettingsClause {
pub names: Option<Expr>,
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ShowTransactionsClause {
pub ids: Vec<Expr>,
pub yields: YieldList,
pub where_expr: Option<Expr>,
pub stages: Vec<PageStage>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TerminateTransactionsClause {
pub ids: Vec<Expr>,
pub yields: YieldList,
}