Merge remote-tracking branch 'origin/parsing' into server-work
# Conflicts: # Cargo.lock # minisql/src/interpreter.rs # server/Cargo.toml # server/src/main.rs
This commit is contained in:
commit
595b47dc06
19 changed files with 1113 additions and 30 deletions
|
|
@ -58,6 +58,16 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
/// TODO: return a reference to avoid allocations
|
||||
pub fn metadata<'a>(&'a self) -> Vec<(String, &'a TableSchema)> {
|
||||
let mut m = Vec::new();
|
||||
for (name, pos) in &self.table_name_position_mapping {
|
||||
let table_schema = self.tables.get(*pos).unwrap().schema();
|
||||
m.push((name.clone(), table_schema));
|
||||
}
|
||||
m
|
||||
}
|
||||
|
||||
fn table_from_name<'a>(&'a self, table_name: &TableName) -> DbResult<&'a Table> {
|
||||
match self.table_name_position_mapping.get_by_left(table_name) {
|
||||
Some(table_position) => {
|
||||
|
|
@ -654,4 +664,4 @@ pub fn example() {
|
|||
println!("{:?}", response);
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ use std::collections::HashMap;
|
|||
pub struct TableSchema {
|
||||
table_name: TableName, // used for descriptive errors
|
||||
primary_key: ColumnPosition,
|
||||
column_name_position_mapping: BiMap<ColumnName, ColumnPosition>,
|
||||
types: Vec<DbType>,
|
||||
pub column_name_position_mapping: BiMap<ColumnName, ColumnPosition>,
|
||||
pub types: Vec<DbType>,
|
||||
}
|
||||
|
||||
pub type TableName = String;
|
||||
|
|
@ -113,7 +113,7 @@ impl TableSchema {
|
|||
}
|
||||
}
|
||||
|
||||
fn number_of_columns(&self) -> usize {
|
||||
pub fn number_of_columns(&self) -> usize {
|
||||
self.column_name_position_mapping.len()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::error::TypeConversionError;
|
||||
|
||||
// ==============Types================
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum DbType {
|
||||
String,
|
||||
Int,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue