Skip to content

Commit f15bb26

Browse files
committed
Fixed issue orientechnologies#1832 about fetching MAP with non document links
1 parent 64fcc2f commit f15bb26

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

core/src/main/java/com/orientechnologies/orient/core/fetch/OFetchHelper.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -432,21 +432,26 @@ private static void fetchMap(final ORecordSchemaAware<?> iRootRecord, final Obje
432432
final Object o = linked.get(key);
433433

434434
if (o instanceof OIdentifiable) {
435-
final ODocument d = ((OIdentifiable) o).getRecord();
436-
if (d != null) {
437-
// GO RECURSIVELY
438-
final Integer fieldDepthLevel = parsedRecords.get(d.getIdentity());
439-
if (!d.getIdentity().isValid() || (fieldDepthLevel != null && fieldDepthLevel.intValue() == iLevelFromRoot)) {
440-
removeParsedFromMap(parsedRecords, d);
441-
iContext.onBeforeDocument(iRootRecord, d, key.toString(), iUserObject);
442-
final Object userObject = iListener.fetchLinkedMapEntry(iRootRecord, iUserObject, fieldName, key.toString(), d,
443-
iContext);
444-
processRecord(d, userObject, iFetchPlan, iCurrentLevel, iLevelFromRoot, iFieldDepthLevel, parsedRecords,
445-
iFieldPathFromRoot, iListener, iContext, "");
446-
iContext.onAfterDocument(iRootRecord, d, key.toString(), iUserObject);
447-
} else {
448-
iListener.parseLinked(iRootRecord, d, iUserObject, key.toString(), iContext);
449-
}
435+
final ORecordInternal<?> r = ((OIdentifiable) o).getRecord();
436+
if (r != null) {
437+
if (r instanceof ODocument) {
438+
// GO RECURSIVELY
439+
final ODocument d = (ODocument) r;
440+
final Integer fieldDepthLevel = parsedRecords.get(d.getIdentity());
441+
if (!d.getIdentity().isValid() || (fieldDepthLevel != null && fieldDepthLevel.intValue() == iLevelFromRoot)) {
442+
removeParsedFromMap(parsedRecords, d);
443+
iContext.onBeforeDocument(iRootRecord, d, key.toString(), iUserObject);
444+
final Object userObject = iListener.fetchLinkedMapEntry(iRootRecord, iUserObject, fieldName, key.toString(), d,
445+
iContext);
446+
processRecord(d, userObject, iFetchPlan, iCurrentLevel, iLevelFromRoot, iFieldDepthLevel, parsedRecords,
447+
iFieldPathFromRoot, iListener, iContext, "");
448+
iContext.onAfterDocument(iRootRecord, d, key.toString(), iUserObject);
449+
} else {
450+
iListener.parseLinked(iRootRecord, d, iUserObject, key.toString(), iContext);
451+
}
452+
} else
453+
iListener.parseLinked(iRootRecord, r, iUserObject, key.toString(), iContext);
454+
450455
}
451456
} else if (o instanceof Map) {
452457
fetchMap(iRootRecord, iUserObject, iFetchPlan, o, key.toString(), iCurrentLevel + 1, iLevelFromRoot, iFieldDepthLevel,

0 commit comments

Comments
 (0)