Skip to content

Commit

Permalink
fixing some lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonShin committed Jul 27, 2024
1 parent 669bb4c commit 0ccac2d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 35 deletions.
1 change: 0 additions & 1 deletion src/ts_generator/information_schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bb8::Pool;
use mysql_async::prelude::Queryable;
use mysql_async::prelude::*;
use std::collections::HashMap;
use tokio::sync::Mutex;
use crate::common::errors::{DB_CONN_POOL_RETRIEVE_ERROR, DB_SCHEME_READ_ERROR};
Expand Down
61 changes: 29 additions & 32 deletions src/ts_generator/sql_parser/expressions/translate_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ pub async fn translate_expr(
if idents.len() == 2 {
let ident = idents[1].value.clone();

let table_name = translate_table_from_expr(table_with_joins, expr)
// todo, we should be throwing identifier without table and give enough context
.ok_or_else(|| TsGeneratorError::IdentifierWithoutTable(expr.to_string()))?;
let table_name = translate_table_from_expr(table_with_joins, expr)?;

let table_details = &DB_SCHEMA
.lock()
Expand Down Expand Up @@ -296,13 +294,13 @@ pub async fn translate_expr(
Ok(())
}
Expr::AnyOp {
left,
compare_op,
left: _,
compare_op: _,
right: expr,
}
| Expr::AllOp {
left,
compare_op,
left: _,
compare_op: _,
right: expr,
} => {
translate_expr(
Expand Down Expand Up @@ -406,13 +404,13 @@ pub async fn translate_expr(
ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, expr_for_logging)?;
ts_query.insert_param(&TsFieldType::Number, &Some(expr.to_string()))
}
Expr::Position { expr, r#in } => {
Expr::Position { expr: _, r#in: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, expr_for_logging)
}
Expr::Substring {
expr,
substring_from,
substring_for,
substring_from: _,
substring_for: _,
special: _,
} => {
ts_query.insert_result(alias, &[TsFieldType::String], is_selection, expr_for_logging)?;
Expand All @@ -438,41 +436,40 @@ pub async fn translate_expr(
ts_query.insert_param(&TsFieldType::Number, &Some(overlay_from.to_string()))?;
ts_query.insert_result(alias, &[TsFieldType::String], is_selection, expr_for_logging)
}
Expr::Collate { expr, collation } => {
ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging)
}
Expr::IntroducedString { introducer, value } => {
Expr::Collate { expr: _, collation: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging)
}
Expr::TypedString { data_type, value } => {
Expr::IntroducedString { introducer: _, value: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging)
}
Expr::MapAccess { column, keys } => {
Expr::TypedString { data_type: _, value: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging)
}
Expr::AggregateExpressionWithFilter { expr, filter } => {
Expr::MapAccess { column: _, keys: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging)
}
Expr::Case {
operand: _,
conditions: _,
results: _,
else_result: _,
} => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging),
Expr::Exists { subquery, negated: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Boolean], is_selection, expr_for_logging)?;
translate_query(ts_query, &None, subquery, db_conn, alias, false).await
}
Expr::ListAgg(_)
| Expr::ArrayAgg(_)
| Expr::GroupingSets(_)
Expr::AggregateExpressionWithFilter { expr: _, filter: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging)
}
Expr::Case {
operand: _,
conditions: _,
results: _,
else_result: _,
} => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging),
Expr::Exists { subquery, negated: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Boolean], is_selection, expr_for_logging)?;
translate_query(ts_query, &None, subquery, db_conn, alias, false).await
}
Expr::ListAgg(_)
| Expr::ArrayAgg(_)
| Expr::GroupingSets(_)
| Expr::Cube(_)
| Expr::Rollup(_)
| Expr::Tuple(_)
| Expr::Array(_)
| Expr::ArraySubquery(_) => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging),
Expr::ArrayIndex { obj, indexes } => {
Expr::ArrayIndex { obj: _, indexes: _ } => {
ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging)
}
Expr::Interval(_) => ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, expr_for_logging),
Expand Down Expand Up @@ -533,7 +530,7 @@ pub async fn translate_expr(
.await
}
Expr::InUnnest {
expr,
expr: _,
array_expr: _,
negated: _,
} => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn find_table_name_from_identifier(
///
pub fn translate_table_from_expr(table_with_joins: &Option<Vec<TableWithJoins>>, expr: &Expr) -> Result<String, TsGeneratorError> {
if table_with_joins.is_none() {
return Err(TsGeneratorError::UnknownErrorWhileProcessingTableWithJoins("".to_string()));
return Err(TsGeneratorError::UnknownErrorWhileProcessingTableWithJoins(expr.to_string()));
}

let table_with_joins = table_with_joins.as_ref().unwrap();
Expand All @@ -134,7 +134,7 @@ pub fn translate_table_from_expr(table_with_joins: &Option<Vec<TableWithJoins>>,
.collect();
find_table_name_from_identifier(table_with_joins, identifiers)
}
_ => Err(TsGeneratorError::UnknownErrorWhileProcessingTableWithJoins("".to_string())),
_ => Err(TsGeneratorError::UnknownErrorWhileProcessingTableWithJoins(expr.to_string())),
}
}

Expand Down

0 comments on commit 0ccac2d

Please sign in to comment.