From 56dbd14c46ee68d68003121d810681cd58d5b3d2 Mon Sep 17 00:00:00 2001 From: everpcpc Date: Wed, 18 Oct 2023 18:43:08 +0800 Subject: [PATCH] fix(cli): send formatted query to server (#270) --- cli/src/session.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/src/session.rs b/cli/src/session.rs index 13fa6e3cc..5f8eb8235 100644 --- a/cli/src/session.rs +++ b/cli/src/session.rs @@ -30,6 +30,7 @@ use tokio::io::AsyncWriteExt; use tokio::time::Instant; use tokio_stream::StreamExt; +use crate::ast::format_query; use crate::ast::{TokenKind, Tokenizer}; use crate::config::Settings; use crate::config::TimeOption; @@ -311,11 +312,12 @@ impl Session { return Ok(Some(ServerStats::default())); } + let formatted_query = format_query(query); let start = Instant::now(); let kind = QueryKind::from(query); match (kind, is_repl) { (QueryKind::Update, false) => { - let affected = self.conn.exec(query).await?; + let affected = self.conn.exec(&formatted_query).await?; if is_repl { if affected > 0 { eprintln!( @@ -354,7 +356,7 @@ impl Session { } self.conn.get_files(&args[1], &args[2]).await? } - _ => self.conn.query_iter_ext(query).await?, + _ => self.conn.query_iter_ext(&formatted_query).await?, }; let mut displayer = FormatDisplay::new(