Skip to content

Commit

Permalink
Deal with missing keys more elegantly
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Crossley <[email protected]>
  • Loading branch information
jcrossley3 committed Nov 8, 2024
1 parent 029e27b commit 786aa1b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/src/db/query/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Columns {
ColumnType::Json | ColumnType::JsonBinary
)
})
.find(name_match(self.json_keys.get(field).map_or("", |v| v)))
.find(name_match(self.json_keys.get(field)?))
.map(|(r, d)| {
(
Expr::expr(Expr::col(r.clone()).cast_json_field(field)),
Expand Down Expand Up @@ -357,6 +357,7 @@ mod tests {
assert!(clause(q("missing=gone")).is_err());
assert!(clause(q("").sort("name")).is_ok());
assert!(clause(q("").sort("nope")).is_err());
assert!(clause(q("q=x")).is_err());

Ok(())
}
Expand Down

0 comments on commit 786aa1b

Please sign in to comment.