Skip to content

Commit

Permalink
fix: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
can-keklik committed Sep 2, 2024
1 parent 3db4d47 commit cb586fd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 28 deletions.
22 changes: 11 additions & 11 deletions lykiadb-lang/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
}));
}

Expand Down Expand Up @@ -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(),
}));
}

Expand All @@ -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(),
}))
}
}
2 changes: 1 addition & 1 deletion lykiadb-lang/tests/lang/sql/sql_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ assert_parsing! {
}
]
},
"where": {
"where": {
"@type": "Expr::Binary",
"operation": {
"@type": "NotIn"
Expand Down
15 changes: 11 additions & 4 deletions lykiadb-server/src/engine/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,14 @@ impl VisitorMut<RV, HaltReason> 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)?;
Expand All @@ -487,9 +494,9 @@ impl VisitorMut<RV, HaltReason> 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))
}
Expand Down
5 changes: 4 additions & 1 deletion lykiadb-server/src/plan/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
10 changes: 4 additions & 6 deletions lykiadb-server/src/plan/planner.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -47,7 +46,6 @@ impl Planner {
source: Box::new(node),
predicate: *where_clause.clone(),
}

}
// GROUP BY
// HAVING
Expand Down
10 changes: 5 additions & 5 deletions lykiadb-server/src/value/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down

0 comments on commit cb586fd

Please sign in to comment.