You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "nfsantos (via GitHub)" <gi...@apache.org> on 2023/06/23 10:17:28 UTC

[GitHub] [jackrabbit-oak] nfsantos commented on a diff in pull request #1002: OAK-10324: IN queries on boolean fields should not fail when one of the values cannot be parsed

nfsantos commented on code in PR #1002:
URL: https://github.com/apache/jackrabbit-oak/pull/1002#discussion_r1239643141


##########
oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/PropertyIndexCommonTest.java:
##########
@@ -419,6 +419,28 @@ public void dateQueryWithEmptyValue() throws Exception {
         assertEventually(() -> assertQuery("select [jcr:path] from [nt:base] where [textField] = 'foo'", singletonList("/test/a")));
     }
 
+    @Test
+    public void inQueryWithUnparseableValue() throws Exception {
+        Tree idx = indexOptions.setIndex(
+                root,
+                "test1",
+                indexOptions.createIndex(indexOptions.createIndexDefinitionBuilder(), false, "booleanField")
+        );
+        Tree booleanField = idx.getChild("indexRules").getChild("nt:base").getChild(PROP_NODE).getChild("booleanField");
+        booleanField.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_BOOLEAN);
+        root.commit();
+
+        Tree test = root.getTree("/").addChild("test");
+        test.addChild("a").setProperty("booleanField", true);

Review Comment:
   Maybe add another path with `booleanField=false`, just to ensure that the query is actually filtering the results.
   



##########
oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/PropertyIndexCommonTest.java:
##########
@@ -419,6 +419,28 @@ public void dateQueryWithEmptyValue() throws Exception {
         assertEventually(() -> assertQuery("select [jcr:path] from [nt:base] where [textField] = 'foo'", singletonList("/test/a")));
     }
 
+    @Test
+    public void inQueryWithUnparseableValue() throws Exception {
+        Tree idx = indexOptions.setIndex(
+                root,
+                "test1",
+                indexOptions.createIndex(indexOptions.createIndexDefinitionBuilder(), false, "booleanField")
+        );
+        Tree booleanField = idx.getChild("indexRules").getChild("nt:base").getChild(PROP_NODE).getChild("booleanField");
+        booleanField.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_BOOLEAN);
+        root.commit();
+
+        Tree test = root.getTree("/").addChild("test");
+        test.addChild("a").setProperty("booleanField", true);
+        root.commit();
+
+        assertEventually(() -> {
+            assertQuery("select [jcr:path] from [nt:base] where [booleanField] in('true', 'True')", singletonList("/test/a"));
+            assertQuery("select [jcr:path] from [nt:base] where [booleanField] in('true', 'InvalidBool')", singletonList("/test/a"));

Review Comment:
   What happens if the in list does not contain any valid boolean value? Is it worth to have a test case?



-- 
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@jackrabbit.apache.org

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