Skip to content

Commit 06fe15d

Browse files
borinquenkidCopilot
andcommitted
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 <223556219+Copilot@users.noreply.github.com>
1 parent f18465a commit 06fe15d

4 files changed

Lines changed: 17 additions & 0 deletions

File tree

grails-data-hibernate5/dbmigration/src/test/resources/logback.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
def CONSOLE_LOG_PATTERN = '%d{HH:mm:ss.SSS} [%t] %highlight(%p) %cyan(\\(%logger{39}\\)) %m%n'
2121

2222
appender('STDOUT', ConsoleAppender) {
23+
follow = true
2324
withJansi = true
2425
encoder(PatternLayoutEncoder) {
2526
pattern = CONSOLE_LOG_PATTERN

grails-data-hibernate7/dbmigration/src/test/resources/logback.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
def CONSOLE_LOG_PATTERN = '%d{HH:mm:ss.SSS} [%t] %highlight(%p) %cyan(\\(%logger{39}\\)) %m%n'
2121

2222
appender('STDOUT', ConsoleAppender) {
23+
follow = true
2324
withJansi = true
2425
encoder(PatternLayoutEncoder) {
2526
pattern = CONSOLE_LOG_PATTERN

grails-data-simple/src/main/groovy/org/grails/datastore/mapping/simple/query/SimpleMapQuery.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class SimpleMapQuery extends Query {
9393
def entityList = entityMap.values()
9494

9595
projectionList.each { Query.Projection p ->
96+
if (p instanceof Query.DistinctProjection) {
97+
if (projectionCount == 1) {
98+
results = new ArrayList(entityList).unique()
99+
}
100+
}
96101

97102
if (p instanceof Query.IdProjection) {
98103
if (projectionCount == 1) {

grails-datamapping-core-test/src/test/groovy/grails/gorm/services/ServiceImplSpec.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ class ServiceImplSpec extends Specification {
8484
productService.find("Apple", "Device") == null
8585
}
8686

87+
void "test find all by finder on simple map datastore"() {
88+
given:
89+
new Product(name: "Apple", type: "Fruit").save(flush: true)
90+
new Product(name: "Orange", type: "Fruit").save(flush: true)
91+
92+
expect:
93+
Product.findAllByName("Apple").size() == 1
94+
Product.findAllByTypeLike("Fruit").size() == 2
95+
}
96+
8797
void "test delete by id implementation"() {
8898
given:
8999
Product p1 = new Product(name: "Apple", type:"Fruit").save(flush:true)

0 commit comments

Comments
 (0)