You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by bo...@apache.org on 2026/05/12 15:15:35 UTC

(grails-core) branch 8.0.x-stage-hibernate7 updated: fix: SimpleMapQuery distinct projection and GroovyChangeLogSpec CI log capture

This is an automated email from the ASF dual-hosted git repository.

borinquenkid pushed a commit to branch 8.0.x-stage-hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git


The following commit(s) were added to refs/heads/8.0.x-stage-hibernate7 by this push:
     new 06fe15d021 fix: SimpleMapQuery distinct projection and GroovyChangeLogSpec CI log capture
06fe15d021 is described below

commit 06fe15d0218538bb806cdf4f9f3731b0a76a3224
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Tue May 12 09:44:17 2026 -0500

    fix: SimpleMapQuery distinct projection and GroovyChangeLogSpec CI log capture
    
    - Add DistinctProjection handling in SimpleMapQuery.executeQuery() so
      findAllBy* finders return results on the SimpleMap datastore instead
      of an empty list. FindAllByFinder.adjustQuery() always adds a distinct
      projection; without this handler the projection branch produced no results.
      Regression introduced when H7 routed Iterable<T> findBy* through
      FindAllByImplementer which generates findAllBy* calls.
    
    - Add regression test 'test find all by finder on simple map datastore'
      in ServiceImplSpec to cover findAllByName and findAllByTypeLike on
      the SimpleMap datastore.
    
    - Set follow=true on Logback ConsoleAppender in both H5 and H7
      dbmigration test logback.groovy. Without this Logback caches the
      System.out reference at initialisation time (before Spock's
      StandardStreamsCapturer wraps it), so Liquibase log output misses
      the @OutputCapture listener. follow=true makes Logback re-resolve
      System.out on every write, matching the currently-active capture
      stream. This fixes GroovyChangeLogSpec CI failures in the Groovy
      Joint Validation Build where the Groovy snapshot changes the
      transitive classpath and Liquibase switches to the SLF4J backend.
    
    Co-authored-by: Copilot <22...@users.noreply.github.com>
---
 .../dbmigration/src/test/resources/logback.groovy              |  1 +
 .../dbmigration/src/test/resources/logback.groovy              |  1 +
 .../datastore/mapping/simple/query/SimpleMapQuery.groovy       |  5 +++++
 .../test/groovy/grails/gorm/services/ServiceImplSpec.groovy    | 10 ++++++++++
 4 files changed, 17 insertions(+)

diff --git a/grails-data-hibernate5/dbmigration/src/test/resources/logback.groovy b/grails-data-hibernate5/dbmigration/src/test/resources/logback.groovy
index f4b25c65a2..f2fbcb6c9b 100644
--- a/grails-data-hibernate5/dbmigration/src/test/resources/logback.groovy
+++ b/grails-data-hibernate5/dbmigration/src/test/resources/logback.groovy
@@ -20,6 +20,7 @@
 def CONSOLE_LOG_PATTERN = '%d{HH:mm:ss.SSS} [%t] %highlight(%p) %cyan(\\(%logger{39}\\)) %m%n'
 
 appender('STDOUT', ConsoleAppender) {
+    follow = true
     withJansi = true
     encoder(PatternLayoutEncoder) {
         pattern = CONSOLE_LOG_PATTERN
diff --git a/grails-data-hibernate7/dbmigration/src/test/resources/logback.groovy b/grails-data-hibernate7/dbmigration/src/test/resources/logback.groovy
index f4b25c65a2..f2fbcb6c9b 100644
--- a/grails-data-hibernate7/dbmigration/src/test/resources/logback.groovy
+++ b/grails-data-hibernate7/dbmigration/src/test/resources/logback.groovy
@@ -20,6 +20,7 @@
 def CONSOLE_LOG_PATTERN = '%d{HH:mm:ss.SSS} [%t] %highlight(%p) %cyan(\\(%logger{39}\\)) %m%n'
 
 appender('STDOUT', ConsoleAppender) {
+    follow = true
     withJansi = true
     encoder(PatternLayoutEncoder) {
         pattern = CONSOLE_LOG_PATTERN
diff --git a/grails-data-simple/src/main/groovy/org/grails/datastore/mapping/simple/query/SimpleMapQuery.groovy b/grails-data-simple/src/main/groovy/org/grails/datastore/mapping/simple/query/SimpleMapQuery.groovy
index b542c9f5d6..e684ea6407 100644
--- a/grails-data-simple/src/main/groovy/org/grails/datastore/mapping/simple/query/SimpleMapQuery.groovy
+++ b/grails-data-simple/src/main/groovy/org/grails/datastore/mapping/simple/query/SimpleMapQuery.groovy
@@ -93,6 +93,11 @@ class SimpleMapQuery extends Query {
             def entityList = entityMap.values()
 
             projectionList.each { Query.Projection p ->
+                if (p instanceof Query.DistinctProjection) {
+                    if (projectionCount == 1) {
+                        results = new ArrayList(entityList).unique()
+                    }
+                }
 
                 if (p instanceof Query.IdProjection) {
                     if (projectionCount == 1) {
diff --git a/grails-datamapping-core-test/src/test/groovy/grails/gorm/services/ServiceImplSpec.groovy b/grails-datamapping-core-test/src/test/groovy/grails/gorm/services/ServiceImplSpec.groovy
index 2c5f5bd345..d1242d0284 100644
--- a/grails-datamapping-core-test/src/test/groovy/grails/gorm/services/ServiceImplSpec.groovy
+++ b/grails-datamapping-core-test/src/test/groovy/grails/gorm/services/ServiceImplSpec.groovy
@@ -84,6 +84,16 @@ class ServiceImplSpec extends Specification {
         productService.find("Apple", "Device") == null
     }
 
+    void "test find all by finder on simple map datastore"() {
+        given:
+        new Product(name: "Apple", type: "Fruit").save(flush: true)
+        new Product(name: "Orange", type: "Fruit").save(flush: true)
+
+        expect:
+        Product.findAllByName("Apple").size() == 1
+        Product.findAllByTypeLike("Fruit").size() == 2
+    }
+
     void "test delete by id implementation"() {
         given:
         Product p1 = new Product(name: "Apple", type:"Fruit").save(flush:true)