From 482145a9087de8cec3688f7a23098a7c03dc690c Mon Sep 17 00:00:00 2001 From: Krassimir Valev Date: Mon, 17 Feb 2025 23:33:13 +0100 Subject: [PATCH] feat(server): search by partial asset path Similarly to how one can search by partial filename, change the path search to work with partial matches instead of looking for a full match. --- server/src/entities/asset.entity.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/entities/asset.entity.ts b/server/src/entities/asset.entity.ts index 1a7d3ee1c1..8ff4130edd 100644 --- a/server/src/entities/asset.entity.ts +++ b/server/src/entities/asset.entity.ts @@ -394,7 +394,9 @@ export function searchAssetBuilder(kysely: Kysely, options: AssetSearchBuild .$if(!!options.libraryId, (qb) => qb.where('assets.libraryId', '=', asUuid(options.libraryId!))) .$if(!!options.userIds, (qb) => qb.where('assets.ownerId', '=', anyUuid(options.userIds!))) .$if(!!options.encodedVideoPath, (qb) => qb.where('assets.encodedVideoPath', '=', options.encodedVideoPath!)) - .$if(!!options.originalPath, (qb) => qb.where('assets.originalPath', '=', options.originalPath!)) + .$if(!!options.originalPath, (qb) => + qb.where(sql`f_unaccent(assets."originalPath")`, 'ilike', sql`'%' || f_unaccent(${options.originalPath}) || '%'`), + ) .$if(!!options.originalFileName, (qb) => qb.where( sql`f_unaccent(assets."originalFileName")`,