Skip to content

Commit 692c8dd

Browse files
authored
SDK - Fix null results field when doing document search and getting no results (#1357)
1 parent 5022620 commit 692c8dd

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

pgml-sdks/pgml/src/collection.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,13 @@ impl Collection {
641641
.await;
642642

643643
match results {
644-
Ok(r) => Ok(r.0),
644+
Ok(r) => {
645+
let mut results = r.0;
646+
if results["results"].is_null() {
647+
results["results"] = json!([]);
648+
}
649+
Ok(results)
650+
}
645651
Err(e) => match e.as_database_error() {
646652
Some(d) => {
647653
if d.code() == Some(Cow::from("XX000")) {
@@ -655,7 +661,11 @@ impl Collection {
655661
let results: (Json,) = sqlx::query_as_with(&built_query, values)
656662
.fetch_one(&pool)
657663
.await?;
658-
Ok(results.0)
664+
let mut results = results.0;
665+
if results["results"].is_null() {
666+
results["results"] = json!([]);
667+
}
668+
Ok(results)
659669
} else {
660670
Err(anyhow::anyhow!(e))
661671
}
@@ -672,7 +682,11 @@ impl Collection {
672682
let results: (Json,) = sqlx::query_as_with(&built_query, values)
673683
.fetch_one(&pool)
674684
.await?;
675-
Ok(results.0)
685+
let mut results = results.0;
686+
if results["results"].is_null() {
687+
results["results"] = json!([]);
688+
}
689+
Ok(results)
676690
}
677691

678692
#[instrument(skip(self))]

0 commit comments

Comments
 (0)
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