build-test-data
build-test-data copied to clipboard
Calling get on base class after building subclass instance does not work
Having two domain classes, when one extends the other using tablePerHierarchy mechanism produces strange results when building test data.
How to reproduce:
- Create base domain class
Base - Create domain class
SubclassextendingBase - Inside test build instance of
Subclassdef instance = Subclass.build() - Running
Base.get(instance.id)results innullwhereas it should returninstanceobject
Workaround:
Running Base.list() or Subclass.list() before the get fixes the issue.
GitHub with reproduction:
https://github.com/piotrgajow/Sandbox/tree/grails-BuildTestDataPlugin-InheritanceIssue
All of tests from this specification pass.
Environment:
Plugin: 3.0.1 OS: Windows 10 Gradle: 3.4.1 Grails: 3.2.8 Groovy: 2.4.7 JVM: 1.8.0_131
I have also found out, that calling load or findById methods do work.