-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support token filter with translated value
- Loading branch information
1 parent
77a9662
commit 8327350
Showing
4 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...hisp/dhis/db/migration/2.41/V2_41_39__Create_jsonb_function_search_translations_token.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
Find translated value that matches given token and given locale. | ||
@param $1 the translations column name | ||
@param $2 the properties to search for (array of strings such as '{NAME,SHORT_NAME}') | ||
@param $3 the locale language to search for | ||
@param $4 the token to search (example : '(?=.*année)') | ||
*/ | ||
CREATE OR replace FUNCTION jsonb_search_translated_token(jsonb, text, text, text) | ||
RETURNS bool | ||
AS $$ | ||
SELECT exists( | ||
SELECT 1 | ||
FROM jsonb_array_elements($1) trans | ||
WHERE trans->>'property' = ANY ($2::text[]) | ||
AND trans->>'locale' = $3 | ||
AND trans->>'value' ~* $4 | ||
); | ||
$$ | ||
LANGUAGE SQL IMMUTABLE PARALLEL SAFE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters