You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/02/03 13:13:38 UTC

[GitHub] [ignite] timoninmaxim commented on a change in pull request #9788: IGNITE-16446: Fix IndexQuery incorrect work with indexes built for _VAL field

timoninmaxim commented on a change in pull request #9788:
URL: https://github.com/apache/ignite/pull/9788#discussion_r798549007



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/reducer/IndexQueryReducer.java
##########
@@ -138,12 +138,29 @@ public IndexQueryReducer(
 
         /** */
         private IndexKey key(String key, int type, IgniteBiTuple<?, ?> entry) throws IgniteCheckedException {
-            GridQueryProperty prop = typeDesc.property(key);
+            Object o;
 
-            // PrimaryKey field.
-            Object o = prop == null ? entry.getKey() : prop.value(entry.getKey(), entry.getValue());
+            if (isKeyField(key))
+                o = entry.getKey();
+            else if (isValueField(key))
+                o = entry.getValue();
+            else {
+                GridQueryProperty prop = typeDesc.property(key);
+
+                o = prop.value(entry.getKey(), entry.getValue());
+            }
 
             return IndexKeyFactory.wrap(o, type, cctx.cacheObjectContext(), meta.keyTypeSettings());
         }
+
+        /** */
+        private boolean isKeyField(String fld) {
+            return fld.equals(typeDesc.keyFieldAlias()) || fld.equals(QueryUtils.KEY_FIELD_NAME);

Review comment:
       `fld`, `keyFieldAlias` are already normalized here, so it is impossible to fail with getting non-normalized keys here.
   
   But, also we should keep in mind the `CacheConfiguration#sqlEscapeAll()` flag. In case it set up, a user have to specify field in the same way as it was declared. For example, if field declared as "f1", then with `sqlEscapeAll=false` it will be normalized to "F1" and user can query it with both "f1" or "F1". But if `sqlEscapeAll=true`, then field will be "f1" and user has to run query with "f1" attribute only, and it's prohibited to use "F1" for querying. 
   
   So `String#equals` works in both cases with or without escaping. I added tests for that.




-- 
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: notifications-unsubscribe@ignite.apache.org

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