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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]