Skip to content

Commit

Permalink
fix(cli): ast pretty_statement panic when version different (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
b41sh authored Jul 14, 2024
1 parent 8a6b664 commit ded4cf8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cli/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ pub fn format_query(query: &str) -> String {
if kind == QueryKind::Put || kind == QueryKind::Get {
return query.to_owned();
}
let tokens = databend_common_ast::parser::tokenize_sql(query).unwrap();
let (stmt, _) = parse_sql(&tokens, Dialect::Experimental).unwrap();
pretty_statement(stmt, 80).unwrap()
if let Ok(tokens) = databend_common_ast::parser::tokenize_sql(query) {
if let Ok((stmt, _)) = parse_sql(&tokens, Dialect::Experimental) {
return pretty_statement(stmt, 80).unwrap();
}
}
query.to_string()
}

0 comments on commit ded4cf8

Please sign in to comment.