Compare commits

...

1 Commits

Author SHA1 Message Date
Gaauwe Rombouts
be9f598e88 chore(collab): update extensions filter to conside description
Update the condition built by `Database.get_extensions` in order to also
apply the same `ILIKE` filter on the `extension_version.description`
column so that, if provided, a search filter can match on either the
extension's name or description.

The `backend-postgres` feature is also added to the `sea-query` crate so
that we can access the `ilike` method, which would otherwise not be
available even though we now we're running a Postgres database.

Co-authored-by: dino <dinojoaocosta@gmail.com>
2025-12-16 13:19:53 +01:00
3 changed files with 26 additions and 1 deletions

16
Cargo.lock generated
View File

@@ -3336,6 +3336,7 @@ dependencies = [
"scrypt",
"sea-orm",
"sea-orm-macros",
"sea-query",
"semver",
"serde",
"serde_json",
@@ -14427,6 +14428,7 @@ dependencies = [
"inherent",
"ordered-float 4.6.0",
"rust_decimal",
"sea-query-derive",
"serde_json",
"time",
"uuid",
@@ -14448,6 +14450,20 @@ dependencies = [
"uuid",
]
[[package]]
name = "sea-query-derive"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bae0cbad6ab996955664982739354128c58d16e126114fe88c2a493642502aab"
dependencies = [
"darling",
"heck 0.4.1",
"proc-macro2",
"quote",
"syn 2.0.106",
"thiserror 2.0.17",
]
[[package]]
name = "seahash"
version = "4.1.0"

View File

@@ -49,6 +49,7 @@ rpc.workspace = true
scrypt = "0.11"
# sea-orm and sea-orm-macros versions must match exactly.
sea-orm = { version = "=1.1.10", features = ["sqlx-postgres", "postgres-array", "runtime-tokio-rustls", "with-uuid"] }
sea-query = { version = "=0.32.7", features = ["backend-postgres"]}
sea-orm-macros = "=1.1.10"
semver.workspace = true
serde.workspace = true

View File

@@ -3,6 +3,7 @@ use std::str::FromStr;
use anyhow::Context;
use chrono::Utc;
use sea_orm::sea_query::IntoCondition;
use sea_query::extension::postgres::PgExpr;
use util::ResultExt;
use super::*;
@@ -25,7 +26,14 @@ impl Database {
.add(extension_version::Column::SchemaVersion.lte(max_schema_version));
if let Some(filter) = filter {
let fuzzy_name_filter = Self::fuzzy_like_string(filter);
condition = condition.add(Expr::cust_with_expr("name ILIKE $1", fuzzy_name_filter));
condition = condition.add(
Condition::any()
.add(Expr::col(extension::Column::Name).ilike(&fuzzy_name_filter))
.add(
Expr::col(extension_version::Column::Description)
.ilike(&fuzzy_name_filter),
),
)
}
if let Some(provides_filter) = provides_filter {