use crate::db::{
query::intent::StructuralQuery,
session::sql::cache::SqlCompiledCommandCacheKey,
sql::{
lowering::{LoweredSqlCommand, SqlGlobalAggregateCommandCore},
parser::{SqlInsertStatement, SqlReturningProjection, SqlUpdateStatement},
},
};
use std::sync::Arc;
#[derive(Clone, Debug)]
pub(in crate::db) enum CompiledSqlCommand {
Select {
query: Arc<StructuralQuery>,
compiled_cache_key: SqlCompiledCommandCacheKey,
},
Delete {
query: Arc<StructuralQuery>,
returning: Option<SqlReturningProjection>,
},
GlobalAggregate {
command: Box<SqlGlobalAggregateCommandCore>,
},
Explain(Box<LoweredSqlCommand>),
Insert(SqlInsertStatement),
Update(SqlUpdateStatement),
DescribeEntity,
ShowIndexesEntity,
ShowColumnsEntity,
ShowEntities,
}
#[derive(Clone, Debug)]
pub(in crate::db) struct SqlProjectionContract {
columns: Vec<String>,
fixed_scales: Vec<Option<u32>>,
}
impl SqlProjectionContract {
#[must_use]
pub(in crate::db) const fn new(columns: Vec<String>, fixed_scales: Vec<Option<u32>>) -> Self {
Self {
columns,
fixed_scales,
}
}
#[must_use]
pub(in crate::db) fn into_parts(self) -> (Vec<String>, Vec<Option<u32>>) {
(self.columns, self.fixed_scales)
}
}