From e1a24fcf135279615746c66899e191cc336a7cf4 Mon Sep 17 00:00:00 2001 From: SilasMarvin <19626586+SilasMarvin@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:08:36 -0800 Subject: [PATCH] SDK - Catch null from JSON_AGG and make it an empty array --- pgml-sdks/pgml/src/collection.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pgml-sdks/pgml/src/collection.rs b/pgml-sdks/pgml/src/collection.rs index 5d43c6a3d..a343920b1 100644 --- a/pgml-sdks/pgml/src/collection.rs +++ b/pgml-sdks/pgml/src/collection.rs @@ -641,7 +641,13 @@ impl Collection { .await; match results { - Ok(r) => Ok(r.0), + Ok(r) => { + let mut results = r.0; + if results["results"].is_null() { + results["results"] = json!([]); + } + Ok(results) + } Err(e) => match e.as_database_error() { Some(d) => { if d.code() == Some(Cow::from("XX000")) { @@ -655,7 +661,11 @@ impl Collection { let results: (Json,) = sqlx::query_as_with(&built_query, values) .fetch_one(&pool) .await?; - Ok(results.0) + let mut results = results.0; + if results["results"].is_null() { + results["results"] = json!([]); + } + Ok(results) } else { Err(anyhow::anyhow!(e)) } @@ -672,7 +682,11 @@ impl Collection { let results: (Json,) = sqlx::query_as_with(&built_query, values) .fetch_one(&pool) .await?; - Ok(results.0) + let mut results = results.0; + if results["results"].is_null() { + results["results"] = json!([]); + } + Ok(results) } #[instrument(skip(self))] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy