in getNodeByRelation, check for manually set subnodeRelation
for additional constraints.
This commit is contained in:
parent
eb0c453cc0
commit
0ea389b663
1 changed files with 28 additions and 18 deletions
|
@ -877,10 +877,20 @@ public final class NodeManager {
|
||||||
TableDataSet tds = null;
|
TableDataSet tds = null;
|
||||||
try {
|
try {
|
||||||
DbMapping dbm = rel.otherType;
|
DbMapping dbm = rel.otherType;
|
||||||
|
|
||||||
tds = new TableDataSet (dbm.getConnection (), dbm.getSchema (), dbm.getKeyDef ());
|
tds = new TableDataSet (dbm.getConnection (), dbm.getSchema (), dbm.getKeyDef ());
|
||||||
String where = rel.buildQuery (home, home.getNonVirtualParent (), kstr, "", false);
|
|
||||||
|
if (home.getSubnodeRelation () != null) {
|
||||||
tds.where (where);
|
// combine our key with the constraints in the manually set subnode relation
|
||||||
|
StringBuffer where = new StringBuffer ();
|
||||||
|
where.append (rel.accessor);
|
||||||
|
where.append (" = '");
|
||||||
|
where.append (escape(kstr));
|
||||||
|
where.append ("' AND ");
|
||||||
|
where.append (home.getSubnodeRelation ().trim().substring(5).trim());
|
||||||
|
tds.where (where.toString ());
|
||||||
|
} else
|
||||||
|
tds.where (rel.buildQuery (home, home.getNonVirtualParent (), kstr, "", false));
|
||||||
|
|
||||||
if (logSql)
|
if (logSql)
|
||||||
app.logEvent ("### getNodeByRelation: "+tds.getSelectString());
|
app.logEvent ("### getNodeByRelation: "+tds.getSelectString());
|
||||||
|
@ -913,21 +923,21 @@ public final class NodeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// a utility method to escape single quotes
|
// a utility method to escape single quotes
|
||||||
/* private String escape (String str) {
|
private String escape (String str) {
|
||||||
if (str == null)
|
if (str == null)
|
||||||
return null;
|
return null;
|
||||||
if (str.indexOf ("'") < 0)
|
if (str.indexOf ("'") < 0)
|
||||||
return str;
|
return str;
|
||||||
int l = str.length();
|
int l = str.length();
|
||||||
StringBuffer sbuf = new StringBuffer (l + 10);
|
StringBuffer sbuf = new StringBuffer (l + 10);
|
||||||
for (int i=0; i<l; i++) {
|
for (int i=0; i<l; i++) {
|
||||||
char c = str.charAt (i);
|
char c = str.charAt (i);
|
||||||
if (c == '\'')
|
if (c == '\'')
|
||||||
sbuf.append ("\\");
|
sbuf.append ("\\");
|
||||||
sbuf.append (c);
|
sbuf.append (c);
|
||||||
}
|
}
|
||||||
return sbuf.toString ();
|
return sbuf.toString ();
|
||||||
} */
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object[] getCacheEntries () {
|
public Object[] getCacheEntries () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue