Do a isStrorageCompatible() rather than isRelational() to handle checks for

non-relational child nodes in isParentOf().
http://helma.org/bugs/show_bug.cgi?id=339#c17
This commit is contained in:
hns 2004-03-12 13:20:59 +00:00
parent 5e13b2c99e
commit b31871fdfb

View file

@ -1358,7 +1358,7 @@ public final class Node implements INode, Serializable {
* @return true if the given node is contained in this node's child list * @return true if the given node is contained in this node's child list
*/ */
public boolean isParentOf(Node n) { public boolean isParentOf(Node n) {
if (dbmap != null && n.isRelational()) { if (dbmap != null) {
Relation subrel = dbmap.getSubnodeRelation(); Relation subrel = dbmap.getSubnodeRelation();
// if we're dealing with relational child nodes use // if we're dealing with relational child nodes use
// Relation.checkConstraints to avoid loading the child index. // Relation.checkConstraints to avoid loading the child index.
@ -1368,6 +1368,11 @@ public final class Node implements INode, Serializable {
if (subrel != null && subrel.otherType != null if (subrel != null && subrel.otherType != null
&& subrel.otherType.isRelational() && subrel.otherType.isRelational()
&& subrel.filter == null) { && subrel.filter == null) {
// first check if types are stored in same table
if (!subrel.otherType.isStorageCompatible(n.getDbMapping())) {
return false;
}
// if they are, check if constraints are met
return subrel.checkConstraints(this, n); return subrel.checkConstraints(this, n);
} }
} }