Validation now outputs a Validated Interpreter Operation
This commit is contained in:
parent
935d9814ae
commit
562e732138
6 changed files with 133 additions and 120 deletions
|
|
@ -18,25 +18,13 @@ pub enum Operation {
|
|||
// DropTable(TableName),
|
||||
}
|
||||
|
||||
pub enum OperationForInterpreter {
|
||||
Select(TablePosition, ColumnSelectionForInterpreter, Option<ConditionForInterpreter>),
|
||||
Insert(TablePosition, InsertionValuesForInterpreter),
|
||||
Delete(TablePosition, Option<ConditionForInterpreter>),
|
||||
CreateTable(TableName, TableSchema),
|
||||
CreateIndex(TablePosition, ColumnPosition),
|
||||
}
|
||||
|
||||
pub type InsertionValues = Vec<(ColumnName, Value)>;
|
||||
|
||||
pub type InsertionValuesForInterpreter = Vec<Value>;
|
||||
|
||||
pub enum ColumnSelection {
|
||||
All,
|
||||
Columns(Vec<ColumnName>),
|
||||
}
|
||||
|
||||
pub type ColumnSelectionForInterpreter = Vec<ColumnPosition>;
|
||||
|
||||
pub enum Condition {
|
||||
// And(Box<Condition>, Box<Condition>),
|
||||
// Or(Box<Condition>, Box<Condition>),
|
||||
|
|
@ -48,11 +36,23 @@ pub enum Condition {
|
|||
// StringCondition(StringCondition),
|
||||
}
|
||||
|
||||
pub enum ConditionForInterpreter {
|
||||
Eq(ColumnPosition, Value),
|
||||
}
|
||||
|
||||
// enum StringCondition {
|
||||
// Prefix(ColumnName, String),
|
||||
// Substring(ColumnName, String),
|
||||
// }
|
||||
|
||||
pub enum OperationForInterpreter {
|
||||
Select(TablePosition, ColumnSelectionForInterpreter, Option<ConditionForInterpreter>),
|
||||
Insert(TablePosition, InsertionValuesForInterpreter),
|
||||
Delete(TablePosition, Option<ConditionForInterpreter>),
|
||||
CreateTable(TableName, TableSchema),
|
||||
CreateIndex(TablePosition, ColumnPosition),
|
||||
}
|
||||
|
||||
pub type InsertionValuesForInterpreter = Vec<Value>;
|
||||
|
||||
pub type ColumnSelectionForInterpreter = Vec<ColumnPosition>;
|
||||
|
||||
pub enum ConditionForInterpreter {
|
||||
Eq(ColumnPosition, Value),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,16 @@ impl TableSchema {
|
|||
self.column_name_position_mapping.get_by_left(column_name).copied()
|
||||
}
|
||||
|
||||
pub fn all_selection(&self) -> ColumnSelectionForInterpreter {
|
||||
self.column_name_position_mapping.iter().map(|(_, column)| *column).collect()
|
||||
}
|
||||
|
||||
// TODO: Rename to get_column
|
||||
pub fn get_column0(&self, column_name: &ColumnName) -> Option<(ColumnPosition, DbType)> {
|
||||
let column = self.get_column_position(column_name)?;
|
||||
Some((column, self.column_type(column)))
|
||||
}
|
||||
|
||||
pub fn get_type_at(&self, column_name: &ColumnName) -> Option<DbType> {
|
||||
let position = self.get_column_position(column_name)?;
|
||||
self.types.get(position).copied()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue