Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian committed Sep 10, 2023
1 parent 409b517 commit 6c1d2ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/completion/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,15 @@ mod tests {

let mut completions = DefaultCompleter::default();
completions.insert(
vec!["nushell", "null", "number"]
["nushell", "null", "number"]
.iter()
.map(|s| s.to_string())
.collect(),
);

assert_eq!(
completions.complete("n", 3),
vec![
[
Suggestion {
value: "null".into(),
description: None,
Expand Down
17 changes: 9 additions & 8 deletions src/history/sqlite_backed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,15 @@ impl SqliteBackedHistory {
SearchDirection::Forward => (true, "asc"),
SearchDirection::Backward => (false, "desc"),
};
let mut wheres: Vec<&str> = vec![];
let mut params: BoxedNamedParams = vec![];
let mut wheres = Vec::new();
let mut params: BoxedNamedParams = Vec::new();
if let Some(start) = query.start_time {
wheres.push(if is_asc {
"timestamp_start > :start_time"
} else {
"timestamp_start < :start_time"
});
params.push((":start_time", Box::new(start.timestamp_millis())))
params.push((":start_time", Box::new(start.timestamp_millis())));
}
if let Some(end) = query.end_time {
wheres.push(if is_asc {
Expand All @@ -288,7 +288,7 @@ impl SqliteBackedHistory {
} else {
"id < :start_id"
});
params.push((":start_id", Box::new(start.0)))
params.push((":start_id", Box::new(start.0)));
}
if let Some(end) = query.end_id {
wheres.push(if is_asc {
Expand Down Expand Up @@ -349,10 +349,11 @@ impl SqliteBackedHistory {
wheres = "true".to_string();
}
let query = format!(
"select {select_expression} from history
where
{wheres}
order by id {asc} {limit}"
"SELECT {select_expression} \
FROM history \
WHERE ({wheres}) \
ORDER BY id {asc} \
{limit}"
);
(query, params)
}
Expand Down

0 comments on commit 6c1d2ec

Please sign in to comment.