validation not cascading on hasOne with abstract class
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Background
Have an existing app that I am trying to upgrade from 2.5 to 4.0. I have a similar kind of domain structure as in my example.
### Steps to reproduce
1. Create a new app with the following classes
```
class Face {
static hasOne = [mouth: Mouth]
static constraints = {
}
}
abstract class Mouth {
Face face
static constraints = {
}
}
class BigMouth extends Mouth {
Integer numberOfTeeth
Boolean tonsilsRemoved
}
```
2. Add the test case
```
import grails.testing.gorm.DomainUnitTest
import spock.lang.Specification
class FaceSpec extends Specification implements DomainUnitTest {
def setup() {
}
def cleanup() {
}
void "test hasOneValidation"() {
when:
domain.mouth = new BigMouth(numberOfTeeth: null)
then:
!domain.validate()
}
}
```
### Expected Behavior
Test case should pass since the validation should fail on BigMouth properties.
### Actual Behavior
Properties on BigMouth are not being validated when validation is called on a Face object. Test case is failing.
### Environment Information
Winodws 10
Oracle JDK 11
Grails 4.0.3
Contributor guide
Research direction
Start by running the FaceSpec reproduction with Face, abstract Mouth, and BigMouth from the issue, checking whether domain.validate() cascades into the hasOne association. Trace the validation path for abstract-class associations and compare the result with the expected invalid BigMouth(numberOfTeeth: null) case. Done means the supplied test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100