borinquenkid commented on code in PR #16818:
URL: https://github.com/apache/grails-core/pull/16818#discussion_r4449305462


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/FunctionCallingCriterionHandler.java:
##########
@@ -77,7 +77,12 @@ public Predicate handle(CriterionContext context, 
FunctionCallingCriterion crite
         } else if (wrapped instanceof Query.In in) {
             Collection<Object> values = new ArrayList<>();
             for (Object v : in.getValues()) {
-                
values.add(convertFunctionValue(context.getConversionService(), functionName, 
v));
+                if (v != null) {
+                    
values.add(convertFunctionValue(context.getConversionService(), functionName, 
v));

Review Comment:
   `WhereQueryFunctionsSpec` covers this: 'function IN criterion filters null 
values, handles all-null and empty lists, and converts numeric function values' 
runs `upper(name) in [...]` and `year(created) in [...]` with mixed-null, 
all-null and empty lists.



##########
grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hibernatequery/PredicateGeneratorSpec.groovy:
##########
@@ -632,6 +632,53 @@ class PredicateGeneratorSpec extends 
HibernateGormDatastoreSpec {
         then:
         thrown(UnsupportedOperationException)
     }
+
+    def "subquery translation does not mutate source criteria projection list 
in-place"() {
+        given:
+        def subCriteria = new 
DetachedCriteria(PredicateGeneratorSpecPerson).eq("lastName", "Smith")
+        List criteria = [
+            new Query.In("id", subCriteria),
+            new Query.EqualsAll("age", subCriteria)
+        ]
+
+        when:
+        def predicates = predicateGenerator.getPredicates(query, root, 
criteria, fromProvider, personEntity)
+
+        then:
+        predicates.length == 2
+        subCriteria.projections.isEmpty()
+    }
+
+    def "property comparison and property name criteria throw 
ConfigurationException on non-existent property"() {
+        when:
+        predicateGenerator.getPredicates(query, root, [criterion], 
fromProvider, personEntity)

Review Comment:
   The invalid-path behavior is now also exercised through the public API in 
`CriteriaInListScenarioSpec` (isNull / eqProperty on an unknown property) on 
both H5 and H7; the direct `PredicateGenerator` specs stay as unit coverage.



-- 
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]

Reply via email to