* Make HopObject.get() behaviour more consistent and predictable: Return null for
non-existing properties that were previously set or are defined in the type mapping, and undefined for non-existing properties that are not defined in the type mapping.
This commit is contained in:
parent
f84ab79675
commit
3e98b1f4bf
1 changed files with 9 additions and 4 deletions
|
@ -859,13 +859,13 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco
|
||||||
Date d = p.getDateValue();
|
Date d = p.getDateValue();
|
||||||
|
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
return NOT_FOUND;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
Object[] args = { new Long(d.getTime()) };
|
Object[] args = { new Long(d.getTime()) };
|
||||||
try {
|
try {
|
||||||
return cx.newObject(core.global, "Date", args);
|
return cx.newObject(core.global, "Date", args);
|
||||||
} catch (JavaScriptException nafx) {
|
} catch (JavaScriptException nafx) {
|
||||||
return NOT_FOUND;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -874,7 +874,7 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco
|
||||||
INode n = p.getNodeValue();
|
INode n = p.getNodeValue();
|
||||||
|
|
||||||
if (n == null) {
|
if (n == null) {
|
||||||
return NOT_FOUND;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return Context.toObject(n, core.global);
|
return Context.toObject(n, core.global);
|
||||||
}
|
}
|
||||||
|
@ -884,12 +884,17 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco
|
||||||
Object obj = p.getJavaObjectValue();
|
Object obj = p.getJavaObjectValue();
|
||||||
|
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return NOT_FOUND;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return Context.toObject(obj, core.global);
|
return Context.toObject(obj, core.global);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DbMapping dbmap = node.getDbMapping();
|
||||||
|
if (dbmap != null && dbmap.propertyToRelation(name) != null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NOT_FOUND;
|
return NOT_FOUND;
|
||||||
|
|
Loading…
Add table
Reference in a new issue