Use RawQuerySyntax for parsing

This commit is contained in:
Yuriy Dupyn 2024-01-27 21:47:33 +01:00
parent 562e732138
commit 9771a89716
10 changed files with 65 additions and 62 deletions

View file

@ -2,7 +2,7 @@ use crate::error::Error;
use crate::internals::row::{ColumnPosition, Row};
use crate::schema::{TableName, TableSchema};
use crate::internals::table::Table;
use crate::operation::{ColumnSelection, Condition, Operation, OperationForInterpreter, ConditionForInterpreter, ColumnSelectionForInterpreter};
use crate::operation::{ColumnSelection, Condition, Operation, OperationForInterpreter, ConditionForInterpreter};
use crate::result::DbResult;
use crate::type_system::{DbType, IndexableValue, Value};
use bimap::BiMap;
@ -27,6 +27,8 @@ pub enum Response<'a> {
IndexCreated,
}
pub type DbSchema<'a> = Vec<(TableName, TablePosition, &'a TableSchema)>;
impl std::fmt::Debug for Response<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
use Response::*;
@ -56,13 +58,13 @@ 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));
pub fn db_schema<'a>(&'a self) -> DbSchema {
let mut schema: DbSchema = Vec::new();
for (table_name, &table_position) in &self.table_name_position_mapping {
let table_schema = self.tables[table_position].schema();
schema.push((table_name.clone(), table_position, table_schema));
}
m
schema
}
// TODO: Get rid of this