The foriegn key declaration should also be modified (in the DDL), when the one side of the oneToMany is Option[] i.e. in :
ALTER TABLE <table identifier>
ADD [ CONSTRAINT <constraint identifier> ]
FOREIGN KEY ( <column expression> {, <column expression>}... )
REFERENCES <table identifier> [ ( <column expression> {, <column expression>}... ) ]
[ ON UPDATE <referential action> ]
[ ON DELETE <referential action> ]
we should have :
ON UPDATE SET NULL
ON DELETE SET NULL
http://www.h2database.com/html/grammar.html#referential_constraint
http://en.wikipedia.org/wiki/Foreign_key(The code that drives the DDL generation is in Schema and DatabaseAdapter...)
Because if we allow the other end (the "one" side of the oneToMany) to be None,
it should translate to NULL in the DB.
So these specs should be added :
1)
"A node should, be able to tolerate the deletion of the parent" in {
.... delete the parent of a node...
}
2)
"A node should, be able to tolerate the setting of it's foreign key to null" in {
.... set parentId of a node to null...
}
Your test seems to do something similar to (1), but it looks like h2 is tolerating it
BTW, what database do you use besides H2 ?
Whatever DB it is, I'll take care of ensuring that it works in the other DBs.
Cheers