You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by GitBox <gi...@apache.org> on 2022/02/24 09:48:12 UTC

[GitHub] [syncope] ilgrosso commented on a change in pull request #317: [SYNCOPE-1664] JSONB: Inconsistent search query when is used a pull correlation rule

ilgrosso commented on a change in pull request #317:
URL: https://github.com/apache/syncope/pull/317#discussion_r813711581



##########
File path: core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnySearchDAO.java
##########
@@ -200,8 +200,11 @@ protected void fillAttrQuery(
                 case EQ:
                     query.append("jsonb_path_exists(").append(schema.getKey()).append(", '$[*] ? ").
                             append("(@.").append(key);
-                    if (isStr) {
+                    if (POSTGRESQL_REGEX_CHARS.chars().mapToObj(c -> (char) c).
+                            anyMatch(c -> value.indexOf(c) > -1) || lower) {
                         query.append(" like_regex \"").append(escapeForLikeRegex(value).replace("'", "''")).append('"');
+                    } else if (isStr) {
+                        query.append(" == \"").append(value).append('"');

Review comment:
       Don't wrap string argument with quotes `"` but single quotes `'`, e.g.
   
   ```
   query.append(" == '").append(value).append("'");
   ```

##########
File path: core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnySearchDAO.java
##########
@@ -200,8 +200,11 @@ protected void fillAttrQuery(
                 case EQ:
                     query.append("jsonb_path_exists(").append(schema.getKey()).append(", '$[*] ? ").
                             append("(@.").append(key);
-                    if (isStr) {
+                    if (POSTGRESQL_REGEX_CHARS.chars().mapToObj(c -> (char) c).

Review comment:
       Replace this condition with simpler
   
   ```
                       if (StringUtils.containsAny(value, POSTGRESQL_REGEX_CHARS) || lower) {
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org