use crate::schema::Udt;
use crate::span::Span;
use crate::types::{CqlType, QueryKind, RelOp};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum StatementKind {
Select,
Insert,
Update,
Delete,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum ParamSource {
Restriction {
column: String,
op: RelOp,
},
Condition {
column: String,
op: RelOp,
},
Assignment {
column: String,
},
ElementKey {
column: String,
},
ElementValue {
column: String,
},
Json,
Expression,
Limit,
PerPartitionLimit,
Ttl,
Timestamp,
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct Param {
pub name: String,
pub cql_type: CqlType,
pub nullable: bool,
pub source: ParamSource,
pub span: Span,
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct ResultColumn {
pub name: String,
pub cql_type: CqlType,
pub nullable: bool,
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct Query {
pub name: String,
pub kind: QueryKind,
pub statement: StatementKind,
pub cql: String,
pub keyspace: Option<String>,
pub table: String,
pub params: Vec<Param>,
pub columns: Vec<ResultColumn>,
pub row_columns: Vec<ResultColumn>,
pub span: Span,
}
#[derive(Clone, Debug, Default, PartialEq)]
#[non_exhaustive]
pub struct Ir {
pub queries: Vec<Query>,
pub udts: Vec<Udt>,
}