groupProperty don't work on Unit Test
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Task List
- [x] Steps to reproduce provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)
### Steps to Reproduce
1. Create a domain class with a group field
2. Insert some data to test
3. Create a Unit Test to check the group by
### Expected Behaviour
The "group by" statement should return a group result
```groovy
new User(name: 'user1', team: 'team1').save(flush: true)
new User(name: 'user2', team: 'team2').save(flush: true)
new User(name: 'user3', team: 'team2').save(flush: true)
def result = User.createCriteria().list {
projections {
groupProperty 'team'
}
}
result.size() == 2
result == [team1, team2]
```
### Actual Behaviour
The "group by" statement return a wrong result
```groovy
new User(name: 'user1', team: 'team1').save(flush: true)
new User(name: 'user2', team: 'team2').save(flush: true)
new User(name: 'user3', team: 'team2').save(flush: true)
def result = User.createCriteria().list {
projections {
groupProperty 'team'
}
}
result.size() == 3 // must be 2
result == [team1, team2, team2]
```
### Environment Information
- **Operating System**: Ubuntu 14.04.1 x86_64
- **GORM Version:** 6.1.6.RELEASE
- **Grails Version (if using Grails):** 3.3.0
- **JDK Version:** 1.8.0_40
### Example Application
[Grails Application with Unit Test to play](https://github.com/mcaligares/gorm-test)
Contributor guide
Research direction
Start with the linked example application and its unit test, reproducing the User.createCriteria() query with projections and groupProperty 'team'. Compare the returned values with the expected two distinct teams; the issue is done when the test produces two grouped results rather than three rows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- database, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100