mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:36:07 +02:00
fix several cases where sort-by was crashing engine-q (#836)
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use nu_protocol::Value;
|
||||
use std::collections::HashSet;
|
||||
|
||||
pub fn get_columns(input: &[Value]) -> Vec<String> {
|
||||
let mut columns = vec![];
|
||||
@ -15,3 +16,23 @@ pub fn get_columns(input: &[Value]) -> Vec<String> {
|
||||
|
||||
columns
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if any of the columns inside the input
|
||||
* does not exist in a vec of columns
|
||||
*/
|
||||
|
||||
pub fn column_does_not_exist(inputs: Vec<String>, columns: Vec<String>) -> bool {
|
||||
let mut set = HashSet::new();
|
||||
for column in columns {
|
||||
set.insert(column);
|
||||
}
|
||||
|
||||
for input in &inputs {
|
||||
if set.contains(input) {
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
Reference in New Issue
Block a user