cargo format
This commit is contained in:
parent
4d45da0cd1
commit
845db102c2
33 changed files with 885 additions and 530 deletions
|
|
@ -1,16 +1,22 @@
|
|||
use minisql::{operation::Operation, interpreter::DbSchema};
|
||||
use crate::syntax::RawQuerySyntax;
|
||||
use minisql::{interpreter::DbSchema, operation::Operation};
|
||||
use nom::{branch::alt, IResult};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{parsing::{create::parse_create, delete::parse_delete, index::parse_create_index, insert::parse_insert, select::parse_select}, validation::{validate_operation, ValidationError}};
|
||||
use crate::{
|
||||
parsing::{
|
||||
create::parse_create, delete::parse_delete, index::parse_create_index,
|
||||
insert::parse_insert, select::parse_select,
|
||||
},
|
||||
validation::{validate_operation, ValidationError},
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error("parsing error: {0}")]
|
||||
ParsingError(String),
|
||||
#[error("validation error: {0}")]
|
||||
ValidationError(#[from] ValidationError)
|
||||
ValidationError(#[from] ValidationError),
|
||||
}
|
||||
|
||||
fn parse_statement(input: &str) -> IResult<&str, RawQuerySyntax> {
|
||||
|
|
@ -21,15 +27,13 @@ fn parse_statement(input: &str) -> IResult<&str, RawQuerySyntax> {
|
|||
//parse_drop,
|
||||
parse_select,
|
||||
// parse_update,
|
||||
parse_create_index
|
||||
parse_create_index,
|
||||
))(input)
|
||||
}
|
||||
|
||||
pub fn parse_and_validate(str_query: String, db_schema: &DbSchema) -> Result<Operation, Error> {
|
||||
let (_, op) = parse_statement(str_query.as_str())
|
||||
.map_err(|err| {
|
||||
Error::ParsingError(err.to_string())
|
||||
})?;
|
||||
let (_, op) =
|
||||
parse_statement(str_query.as_str()).map_err(|err| Error::ParsingError(err.to_string()))?;
|
||||
|
||||
Ok(validate_operation(op, db_schema)?)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue