mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-19 15:05:47 +01:00
fix infinite loop error
This commit is contained in:
41
cli/app.rs
41
cli/app.rs
@@ -434,6 +434,21 @@ impl Limbo {
|
||||
self.input_buff.push(' ');
|
||||
}
|
||||
|
||||
fn run_query(&mut self, input: &str) {
|
||||
let echo = self.opts.echo;
|
||||
if echo {
|
||||
let _ = self.writeln(&input);
|
||||
}
|
||||
let conn = self.conn.clone();
|
||||
let runner = conn.query_runner(input.as_bytes());
|
||||
for output in runner {
|
||||
if let Err(_) = self.print_query_result(&input, output) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.reset_input();
|
||||
}
|
||||
|
||||
pub fn handle_input_line(
|
||||
&mut self,
|
||||
line: &str,
|
||||
@@ -458,17 +473,7 @@ impl Limbo {
|
||||
self.buffer_input(after_comment);
|
||||
|
||||
if after_comment.ends_with(';') {
|
||||
if self.opts.echo {
|
||||
let _ = self.writeln(after_comment);
|
||||
}
|
||||
let conn = self.conn.clone();
|
||||
let runner = conn.query_runner(after_comment.as_bytes());
|
||||
for output in runner {
|
||||
if let Err(e) = self.print_query_result(after_comment, output) {
|
||||
let _ = self.writeln(e.to_string());
|
||||
}
|
||||
}
|
||||
self.reset_input();
|
||||
self.run_query(after_comment);
|
||||
} else {
|
||||
self.set_multiline_prompt();
|
||||
}
|
||||
@@ -489,18 +494,7 @@ impl Limbo {
|
||||
if line.ends_with(';') {
|
||||
self.buffer_input(line);
|
||||
let buff = self.input_buff.clone();
|
||||
let echo = self.opts.echo;
|
||||
if echo {
|
||||
let _ = self.writeln(&buff);
|
||||
}
|
||||
let conn = self.conn.clone();
|
||||
let runner = conn.query_runner(buff.as_bytes());
|
||||
for output in runner {
|
||||
if let Err(e) = self.print_query_result(&buff, output) {
|
||||
let _ = self.writeln(e.to_string());
|
||||
}
|
||||
}
|
||||
self.reset_input();
|
||||
self.run_query(buff.as_str());
|
||||
} else {
|
||||
self.buffer_input(line);
|
||||
self.set_multiline_prompt();
|
||||
@@ -745,6 +739,7 @@ impl Limbo {
|
||||
"{:?}",
|
||||
miette::Error::from(err).with_source_code(sql.to_owned())
|
||||
));
|
||||
anyhow::bail!("We have to throw here, even if we printed error");
|
||||
}
|
||||
}
|
||||
// for now let's cache flush always
|
||||
|
||||
Reference in New Issue
Block a user