aggregate GroovyCastException in version 7.1.0
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
Environment:
Grails 5
GORM 7.1.0
Java 8
Problem:
I'm trying to run this simple code:
```
collection.aggregate(
Arrays.asList(
Aggregates.match(Filters.eq("categories", "Bakery")),
Aggregates.group('$stars', Accumulators.sum("count", 1))
)
).forEach(doc -> System.out.println(doc.toJson()));
```
the system throws this exception:
```
Cannot cast object 'Stage{name='$match', value=Filter{fieldName='categories', value=Bakery}}' with class 'com.mongodb.client.model.Aggregates$SimplePipelineStage' to class 'java.util.Map'.
```
NOTE: Just tested in an empty gradle project with the same mongodb-driver-sync version and it works. and in previous grails version (4.0.12) this code works
why Is grails forcing me to use Map syntax?
Contributor guide
Research direction
Reproduce the aggregation example in Grails 5 with GORM 7.1.0 and Java 8, then compare it with the empty Gradle project and Grails 4.0.12 cases described in the report. Inspect how the MongoDB aggregation stages are handled and determine why a SimplePipelineStage is cast to Map; done means the cause and affected version or behavior are identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, mongodb
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100