summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2023-10-22 13:43:19 +0100
committerdakkar <dakkar@thenautilus.net>2023-10-22 13:43:19 +0100
commit1dc5623713915c2bf3dae93a3473d80e93f96be8 (patch)
tree63b45c14eb837370b3904f6625cdfb9bc145939c /packages/backend/src
parentnicer file type search (diff)
downloadsharkey-1dc5623713915c2bf3dae93a3473d80e93f96be8.tar.gz
sharkey-1dc5623713915c2bf3dae93a3473d80e93f96be8.tar.bz2
sharkey-1dc5623713915c2bf3dae93a3473d80e93f96be8.zip
use block comment
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/SearchService.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/packages/backend/src/core/SearchService.ts b/packages/backend/src/core/SearchService.ts
index 4fd1d72f22..6103b0e0f6 100644
--- a/packages/backend/src/core/SearchService.ts
+++ b/packages/backend/src/core/SearchService.ts
@@ -220,17 +220,17 @@ export class SearchService {
}
if (opts.filetype) {
- // this is very ugly, but the "correct" solution would
- // be `and exists (select 1 from
- // unnest(note."attachedFileTypes") x(t) where t like
- // :type)` and I can't find a way to get TypeORM to
- // generate that; this hack works because `~*` is
- // "regexp match, ignoring case" and the stringified
- // version of an array of varchars (which is what
- // `attachedFileTypes` is) looks like `{foo,bar}`, so
- // we're looking for opts.filetype as the first half
- // of a MIME type, either at start of the array (after
- // the `{`) or later (after a `,`)
+ /* this is very ugly, but the "correct" solution would
+ be `and exists (select 1 from
+ unnest(note."attachedFileTypes") x(t) where t like
+ :type)` and I can't find a way to get TypeORM to
+ generate that; this hack works because `~*` is
+ "regexp match, ignoring case" and the stringified
+ version of an array of varchars (which is what
+ `attachedFileTypes` is) looks like `{foo,bar}`, so
+ we're looking for opts.filetype as the first half of
+ a MIME type, either at start of the array (after the
+ `{`) or later (after a `,`) */
query.andWhere(`note."attachedFileTypes"::varchar ~* :type`, { type: `[{,]${opts.filetype}/` });
}