Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.0.3
-
Fix Version/s: 1.1.1
-
Component/s: None
-
Labels:None
-
Testcase included:yes
Description
It's impossible to map trees with Grails 1.0.3 because you can't allow NULL values for parent attribute of the root node(s).
When this bug is fixed, I'm willing to extend the test project to check all kinds of operations on trees so this bug doesn't show up in any future version of Grails anymore.
-
Hide
- TreeTest.zip
- 17/Jun/08 6:56 AM
- 188 kB
- Aaron Digulla
-
- TreeTest/.classpath 6 kB
- TreeTest/.project 0.5 kB
- TreeTest/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- TreeTest/application.properties 0.1 kB
- TreeTest/build.xml 1 kB
- TreeTest/grails-app/.../BootStrap.groovy 0.1 kB
- TreeTest/grails-app/conf/Config.groovy 3 kB
- TreeTest/grails-app/.../DataSource.groovy 0.6 kB
- TreeTest/grails-app/.../resources.groovy 0.0 kB
- TreeTest/grails-app/.../UrlMappings.groovy 0.2 kB
- TreeTest/.../TreeNodeController.groovy 2 kB
- TreeTest/grails-app/.../TreeNode.groovy 0.3 kB
- TreeTest/grails-app/.../messages.properties 2 kB
- TreeTest/.../messages_de.properties 3 kB
- TreeTest/.../messages_es.properties 3 kB
- TreeTest/.../messages_fr.properties 2 kB
- TreeTest/.../messages_it.properties 2 kB
- TreeTest/.../messages_ja.properties 2 kB
- TreeTest/.../messages_nl.properties 3 kB
- TreeTest/.../messages_pt_BR.properties 3 kB
- TreeTest/.../messages_ru.properties 4 kB
- TreeTest/.../messages_th.properties 5 kB
- TreeTest/.../messages_zh_CN.properties 2 kB
- TreeTest/grails-app/views/error.gsp 1 kB
- TreeTest/grails-app/.../layouts/main.gsp 0.7 kB
- TreeTest/grails-app/.../treeNode/create.gsp 1 kB
- TreeTest/grails-app/.../treeNode/edit.gsp 2 kB
- TreeTest/grails-app/.../treeNode/list.gsp 2 kB
- TreeTest/grails-app/.../treeNode/show.gsp 2 kB
- TreeTest/stacktrace.log 0.0 kB
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
Hi Aaron,
I'm not sure where the problem is that's causing those exceptions but as a workaround, the following domain class passes your test:
class TreeNode {
static hasMany = [ children: TreeNode ]
static belongsTo = [ parent: TreeNode ]
static constraints =
public TreeNode()
{ children = [] }}
basically hasMany and belongsTo will create implicit properties 'parent' and 'children'. The constructor was needed to initialise children to an empty list (which I thought should have been done for you by Grails, which might help track down the problem)
I can confirm that; if either a field "parent" or "children" is defined in the class, the tests fail. As soon as only the automatic properties created by hasMany and belongsTo exist, the error goes away.
I'll extend the test case with the workaround and try the original version with 1.0.4 as soon as the bug if fixed.
New version of TreeTest.zip which works.
Uncomment the lines in TreeNode.groovy to activate the bug
"works" as in "more test cases" and "tests don't fail". There are a couple of comments in the test cases about stuff that doesn't work.
Seems this has been fixed already, since I cannot reproduce the problem with the attached example
It seems that the constraint "parent (nullable: true)" in TreeNode.groovy is ignored.