Skip to content

SDK - Fix null results field when doing document search and getting no results #1357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions pgml-sdks/pgml/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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))
}
Expand All @@ -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))]
Expand Down
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