diff --git a/lykiadb-lang/src/parser/mod.rs b/lykiadb-lang/src/parser/mod.rs index 84225015..834ea912 100644 --- a/lykiadb-lang/src/parser/mod.rs +++ b/lykiadb-lang/src/parser/mod.rs @@ -793,9 +793,9 @@ impl<'a> Parser<'a> { } use crate::ast::sql::{ - SqlCollectionIdentifier, SqlCompoundOperator, SqlDelete, SqlDistinct, SqlFrom, - SqlInsert, SqlJoinType, SqlLimitClause, SqlOrderByClause, SqlOrdering, SqlProjection, - SqlSelect, SqlSelectCompound, SqlSelectCore, SqlUpdate, SqlValues, + SqlCollectionIdentifier, SqlCompoundOperator, SqlDelete, SqlDistinct, SqlFrom, SqlInsert, + SqlJoinType, SqlLimitClause, SqlOrderByClause, SqlOrdering, SqlProjection, SqlSelect, + SqlSelectCompound, SqlSelectCore, SqlUpdate, SqlValues, }; macro_rules! optional_with_expected { @@ -1265,12 +1265,12 @@ impl<'a> Parser<'a> { if let Some(operation) = operation { let right = self.sql_expression()?; - return Ok(Box::new(Expr::Binary { - left: left.clone(), - operation, - right: right.clone(), - span: left.get_span().merge(&right.get_span()), - id: self.get_expr_id() + return Ok(Box::new(Expr::Binary { + left: left.clone(), + operation, + right: right.clone(), + span: left.get_span().merge(&right.get_span()), + id: self.get_expr_id(), })); } @@ -1300,7 +1300,7 @@ impl<'a> Parser<'a> { upper: upper.clone(), kind: RangeKind::NotBetween, span: subject.get_span().merge(&upper.get_span()), - id: self.get_expr_id() + id: self.get_expr_id(), })); } @@ -1310,7 +1310,7 @@ impl<'a> Parser<'a> { upper: upper.clone(), kind: RangeKind::Between, span: subject.get_span().merge(&upper.get_span()), - id: self.get_expr_id() + id: self.get_expr_id(), })) } } diff --git a/lykiadb-lang/tests/lang/sql/sql_expr.rs b/lykiadb-lang/tests/lang/sql/sql_expr.rs index 5fcfd295..db779334 100644 --- a/lykiadb-lang/tests/lang/sql/sql_expr.rs +++ b/lykiadb-lang/tests/lang/sql/sql_expr.rs @@ -151,7 +151,7 @@ assert_parsing! { } ] }, - "where": { + "where": { "@type": "Expr::Binary", "operation": { "@type": "NotIn" diff --git a/lykiadb-server/src/engine/interpreter.rs b/lykiadb-server/src/engine/interpreter.rs index edae7150..621271b7 100644 --- a/lykiadb-server/src/engine/interpreter.rs +++ b/lykiadb-server/src/engine/interpreter.rs @@ -478,7 +478,14 @@ impl VisitorMut for Interpreter { Ok(callable) } - Expr::Range { lower, upper, subject, kind, span, id } => { + Expr::Range { + lower, + upper, + subject, + kind, + span, + id, + } => { let lower_eval = self.visit_expr(lower)?; let upper_eval = self.visit_expr(upper)?; let subject_eval = self.visit_expr(subject)?; @@ -487,9 +494,9 @@ impl VisitorMut for Interpreter { (&lower_eval, &upper_eval, &subject_eval) { match kind { - RangeKind::Between => { - Ok(RV::Bool(lower_num <= subject_num && subject_num <= upper_num)) - } + RangeKind::Between => Ok(RV::Bool( + lower_num <= subject_num && subject_num <= upper_num, + )), RangeKind::NotBetween => { Ok(RV::Bool(lower_num > subject_num || subject_num > upper_num)) } diff --git a/lykiadb-server/src/plan/mod.rs b/lykiadb-server/src/plan/mod.rs index d7e97365..d0466bf0 100644 --- a/lykiadb-server/src/plan/mod.rs +++ b/lykiadb-server/src/plan/mod.rs @@ -1,5 +1,8 @@ use lykiadb_lang::{ - ast::{expr::Expr, sql::{SqlCollectionIdentifier, SqlJoinType, SqlOrdering}}, + ast::{ + expr::Expr, + sql::{SqlCollectionIdentifier, SqlJoinType, SqlOrdering}, + }, Identifier, }; use serde::{Deserialize, Serialize}; diff --git a/lykiadb-server/src/plan/planner.rs b/lykiadb-server/src/plan/planner.rs index dcf70823..d9641d69 100644 --- a/lykiadb-server/src/plan/planner.rs +++ b/lykiadb-server/src/plan/planner.rs @@ -1,9 +1,8 @@ -use lykiadb_lang:: - ast::{ - expr::Expr, - sql::{SqlFrom, SqlJoinType, SqlSelect}, - }; use crate::engine::interpreter::HaltReason; +use lykiadb_lang::ast::{ + expr::Expr, + sql::{SqlFrom, SqlJoinType, SqlSelect}, +}; use super::{Node, Plan}; pub struct Planner; @@ -47,7 +46,6 @@ impl Planner { source: Box::new(node), predicate: *where_clause.clone(), } - } // GROUP BY // HAVING diff --git a/lykiadb-server/src/value/types.rs b/lykiadb-server/src/value/types.rs index fd86cdc1..d2a20191 100644 --- a/lykiadb-server/src/value/types.rs +++ b/lykiadb-server/src/value/types.rs @@ -377,11 +377,11 @@ pub fn eval_binary(left_eval: RV, right_eval: RV, operation: Operation) -> RV { Operation::Divide => left_eval / right_eval, // TODO: Implement operations: /* - Operation::Like - Operation::NotLike - Operation::In - Operation::NotIn - */ + Operation::Like + Operation::NotLike + Operation::In + Operation::NotIn + */ _ => RV::Undefined, } }