Skip to content

Commit

Permalink
fix: convert cql2-text to cql2-json
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Dec 4, 2024
1 parent 89e8c28 commit 40433a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/pgstac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ mod tls;

pub use page::Page;
use serde::{de::DeserializeOwned, Serialize};
use stac_api::Search;
use tokio_postgres::{types::ToSql, GenericClient, Row};
#[cfg(feature = "tls")]
pub use {tls::make_unverified_tls, tokio_postgres_rustls::MakeRustlsConnect};
Expand All @@ -92,6 +93,10 @@ pub enum Error {
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),

/// [stac_api::Error]
#[error(transparent)]
StacApi(#[from] stac_api::Error),

/// [tokio_postgres::Error]
#[error(transparent)]
TokioPostgres(#[from] tokio_postgres::Error),
Expand Down Expand Up @@ -231,12 +236,9 @@ pub trait Pgstac: GenericClient {
}

/// Searches for items.
async fn search<T>(&self, search: T) -> Result<Page>
where
T: Serialize,
{
async fn search(&self, search: Search) -> Result<Page> {
let search = search.into_cql2_json()?;
let search = serde_json::to_value(search)?;
// TODO do we want to check for cql2-text?
self.value("search", &[&search]).await
}

Expand Down

0 comments on commit 40433a5

Please sign in to comment.