Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
can-keklik committed Nov 26, 2024
1 parent 39fa60e commit cb10ba3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lykiadb-server/src/engine/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ impl VisitorMut<RV, HaltReason> for Interpreter {
let callable = RV::Callable(Callable::new(
Some(parameters.len()),
CallableKind::Generic,
fun.into(),
fun,
));

if name.is_some() {
Expand Down
4 changes: 2 additions & 2 deletions lykiadb-server/src/plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ impl Node {
if let Some(c) = collection.as_ref() {
return format!("* in {}", c.name);
}
return format!("*");
"*".to_string()
}
SqlProjection::Expr { expr, alias } => {
if let Some(alias) = alias {
return format!("{} as {}", expr, alias.name);
}
return format!("{} as {}", expr, expr);
format!("{} as {}", expr, expr)
}
})
.collect::<Vec<String>>()
Expand Down
8 changes: 4 additions & 4 deletions lykiadb-server/src/plan/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'a> Planner<'a> {
source: Box::new(node),
offset: self
.interpreter
.visit_expr(&offset)?
.visit_expr(offset)?
.as_number()
.expect("Offset is not correct")
.floor() as usize,
Expand Down Expand Up @@ -164,9 +164,9 @@ pub mod test_helpers {
let mut planner = Planner::new(&mut interpreter);
let program = query.parse::<Program>().unwrap();
match *program.get_root() {
Stmt::Program { body, .. } if matches!(body.get(0), Some(Stmt::Expression { .. })) => {
if let Some(Stmt::Expression { expr, .. }) = body.get(0) {
let generated_plan = planner.build(&expr).unwrap();
Stmt::Program { body, .. } if matches!(body.first(), Some(Stmt::Expression { .. })) => {
if let Some(Stmt::Expression { expr, .. }) = body.first() {
let generated_plan = planner.build(expr).unwrap();
assert_eq!(expected_plan, generated_plan.to_string());
}
}
Expand Down
2 changes: 1 addition & 1 deletion lykiadb-server/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl RV {
pub fn is_in(&self, other: &RV) -> RV {
match (self, other) {
(RV::Str(lhs), RV::Str(rhs)) => RV::Bool(rhs.contains(lhs.as_str())),
(lhs, RV::Array(rhs)) => RV::Bool(rhs.read().unwrap().contains(&lhs)),
(lhs, RV::Array(rhs)) => RV::Bool(rhs.read().unwrap().contains(lhs)),
(RV::Str(key), RV::Object(map)) => {
RV::Bool(map.read().unwrap().contains_key(key.as_str()))
}
Expand Down
8 changes: 4 additions & 4 deletions lykiadb-server/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ fn expect_plan(query: &str, expected_plan: &str) {
let mut planner: Planner<'_> = Planner::new(&mut interpreter);
let program = query.parse::<Program>().unwrap();
match *program.get_root() {
Stmt::Program { body, .. } if matches!(body.get(0), Some(Stmt::Expression { .. })) => {
if let Some(Stmt::Expression { expr, .. }) = body.get(0) {
let generated_plan = planner.build(&expr).unwrap();
Stmt::Program { body, .. } if matches!(body.first(), Some(Stmt::Expression { .. })) => {
if let Some(Stmt::Expression { expr, .. }) = body.first() {
let generated_plan = planner.build(expr).unwrap();
assert_eq!(expected_plan, generated_plan.to_string().trim());
}
}
Expand All @@ -29,6 +29,6 @@ pub fn run_test(input: &str) {
.trim()
.to_string();
let io_parts: Vec<&str> = rest.split("---").collect();
expect_plan(&io_parts[0].trim(), &io_parts[1].trim());
expect_plan(io_parts[0].trim(), io_parts[1].trim());
}
}

0 comments on commit cb10ba3

Please sign in to comment.