Show entire table if number of rows requested for last is greater than table size (#2112)

* Show entire table if number of rows requested for last is greater than table size

* rustfmt

* Add test
This commit is contained in:
Joseph T. Lyons
2020-07-04 21:04:17 -04:00
committed by GitHub
parent 8ea2307815
commit 9e82e5a2fa
2 changed files with 21 additions and 7 deletions

View File

@ -69,16 +69,18 @@ async fn last(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStr
1
};
let mut values_vec_deque = VecDeque::new();
let count = rows_desired as usize;
if count < v.len() {
let k = v.len() - count;
let k = if count < v.len() {
v.len() - count
} else {
return Ok(futures::stream::iter(v).to_output_stream());
};
for x in v[k..].iter() {
values_vec_deque.push_back(ReturnSuccess::value(x.clone()));
}
let mut values_vec_deque = VecDeque::new();
for x in v[k..].iter() {
values_vec_deque.push_back(ReturnSuccess::value(x.clone()));
}
Ok(futures::stream::iter(values_vec_deque).to_output_stream())