Nested criteria querying works incorrectly with mock domain objects
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Task List
- [x] Steps to reproduce provided
- [ ] Stacktrace (if present) provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)
### Steps to Reproduce
1. Download the sample app:
https://github.com/rmorrise/nested-query-mock-test
2. Verify that the app works properly:
`grails run-app`
On the index page, a Grandchild object is rendered as JSON.
3. Execute the unit tests:
`grails test-app`
The TestControllerSpec fails.
### Expected Behaviour
The TestController.index() method should respond with a Grandchild object, causing the test to pass.
### Actual Behaviour
TestController.index() responds with an empty list.
_Note: The test will pass if all of the domain objects have the same ID value._
### Environment Information
- **Operating System**: Win 7 x64
- **Grails Version:** 2.3.8 w/GORM 6.1.0.RELEASE
- **JDK Version:** 1.8.0_121-b13
- **Container Version (If Applicable):** N/A
### Example Application
https://github.com/rmorrise/nested-query-mock-test
Contributor guide
Research direction
Download the nested-query-mock-test example, run `grails test-app`, and inspect the failing TestControllerSpec and its nested domain-object query. Compare the test result with `grails run-app` and the documented expected behavior. Done means TestController.index() responds with the Grandchild object and the test passes when the domain objects have different IDs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend, databases, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100