From 87044338dbaf1ba5424154609fed7a6cf84e9a7e Mon Sep 17 00:00:00 2001 From: ljl <17743125563@163.com> Date: Sat, 6 Jan 2024 11:22:23 +0800 Subject: [PATCH] spi-log:fix ext is nuLL. --- spi/spi-log/src/serv/pg/log_pg_item_serv.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spi/spi-log/src/serv/pg/log_pg_item_serv.rs b/spi/spi-log/src/serv/pg/log_pg_item_serv.rs index cef2b198b..19e8769d0 100644 --- a/spi/spi-log/src/serv/pg/log_pg_item_serv.rs +++ b/spi/spi-log/src/serv/pg/log_pg_item_serv.rs @@ -151,6 +151,26 @@ pub async fn find(find_req: &mut LogItemFindReq, funs: &TardisFunsInst, ctx: &Ta for val in value { sql_vals.push(val); } + } else if ext_item.op == BasicQueryOpKind::NotIn { + let value = value.clone(); + if value.len() == 1 { + where_fragments.push(format!("not (ext -> '{}' ? ${})", ext_item.field, sql_vals.len() + 1)); + } else { + where_fragments.push(format!( + "not (ext -> '{}' ?| array[{}])", + ext_item.field, + (0..value.len()).map(|idx| format!("${}", sql_vals.len() + idx + 1)).collect::>().join(", ") + )); + } + for val in value { + sql_vals.push(val); + } + } else if ext_item.op == BasicQueryOpKind::IsNull { + where_fragments.push(format!("ext ->> '{}' is null", ext_item.field)); + } else if ext_item.op == BasicQueryOpKind::IsNotNull { + where_fragments.push(format!("ext ->> '{}' is not null", ext_item.field)); + } else if ext_item.op == BasicQueryOpKind::IsNullOrEmpty { + where_fragments.push(format!("(ext ->> '{}' is null or ext ->> '{}' = '')", ext_item.field, ext_item.field)); } else { if value.len() > 1 { return err_notfound(ext_item);