Move TablePosition into schema

This commit is contained in:
Yuriy Dupyn 2024-01-28 18:43:53 +01:00
parent a2180a3e32
commit ec0a4f2510
4 changed files with 5 additions and 6 deletions

View file

@ -1,4 +1,4 @@
use crate::schema::{Column, TableName, TableSchema}; use crate::schema::{Column, TableName, TablePosition, TableSchema};
use crate::internals::table::Table; use crate::internals::table::Table;
use crate::operation::{Operation, Condition}; use crate::operation::{Operation, Condition};
use crate::result::DbResult; use crate::result::DbResult;
@ -8,7 +8,6 @@ use crate::restricted_row::RestrictedRow;
// Use `TablePosition` as index // Use `TablePosition` as index
pub type Tables = Vec<Table>; pub type Tables = Vec<Table>;
pub type TablePosition = usize;
// ==============Interpreter================ // ==============Interpreter================
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]

View file

@ -1,6 +1,5 @@
use crate::schema::{Column, TableSchema}; use crate::schema::{Column, TablePosition, TableSchema};
use crate::type_system::Value; use crate::type_system::Value;
use crate::interpreter::TablePosition;
// Validated operation. Constructed by validation crate. // Validated operation. Constructed by validation crate.
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]

View file

@ -16,6 +16,7 @@ pub struct TableSchema {
} }
pub type TableName = String; pub type TableName = String;
pub type TablePosition = usize;
pub type ColumnName = String; pub type ColumnName = String;
pub type Column = usize; pub type Column = usize;

View file

@ -4,7 +4,7 @@ use thiserror::Error;
use crate::syntax; use crate::syntax;
use crate::syntax::{RawTableSchema, ColumnSchema, RawQuerySyntax}; use crate::syntax::{RawTableSchema, ColumnSchema, RawQuerySyntax};
use minisql::operation; use minisql::operation;
use minisql::{operation::Operation, type_system::Value, schema::{TableSchema, ColumnName, TableName}, type_system::DbType, interpreter::{TablePosition, DbSchema}}; use minisql::{operation::Operation, type_system::Value, schema::{TableSchema, ColumnName, Column, TableName, TablePosition}, type_system::DbType, interpreter::DbSchema};
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum ValidationError { pub enum ValidationError {
@ -158,7 +158,7 @@ fn validate_insert(table_name: TableName, insertion_values: syntax::InsertionVal
} }
// Check types and prepare for creation of InsertionValues for the interpreter // Check types and prepare for creation of InsertionValues for the interpreter
let mut values_map: BTreeMap<_, Value> = BTreeMap::new(); // The reason for using BTreeMap let mut values_map: BTreeMap<Column, Value> = BTreeMap::new(); // The reason for using BTreeMap
// instead of HashMap is that we need // instead of HashMap is that we need
// to get the values in a vector // to get the values in a vector
// sorted by the key. // sorted by the key.