From 786aa1bda725abf5d8e9b3310890c735ce07bdc1 Mon Sep 17 00:00:00 2001 From: Jim Crossley Date: Thu, 7 Nov 2024 14:27:38 -0500 Subject: [PATCH] Deal with missing keys more elegantly Signed-off-by: Jim Crossley --- common/src/db/query/columns.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/db/query/columns.rs b/common/src/db/query/columns.rs index c6d6f2f29..d8942fe3c 100644 --- a/common/src/db/query/columns.rs +++ b/common/src/db/query/columns.rs @@ -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)), @@ -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(()) }