Skip to content

Commit

Permalink
fix: first fixes in traverse with variables implementation, issue #10292
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Sep 10, 2024
1 parent fe98cff commit 49efc4d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.orientechnologies.orient.core.record.impl.ODocumentHelper;
import com.orientechnologies.orient.core.serialization.serializer.OStringSerializerHelper;
import com.orientechnologies.orient.core.sql.executor.OExecutionStep;
import com.orientechnologies.orient.core.sql.executor.OResult;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
Expand Down Expand Up @@ -130,8 +131,13 @@ else if (firstPart.equalsIgnoreCase("ROOT")) {
else result = getVariableFromParentHierarchy(firstPart);
}
}

if (pos > -1) result = ODocumentHelper.getFieldValue(result, lastPart, this);
if (pos > -1) {
if (result instanceof OResult) {
result = ODocumentHelper.getFieldValue(((OResult) result).toElement(), lastPart, this);
} else {
result = ODocumentHelper.getFieldValue(result, lastPart, this);
}
}

return result != null ? resolveValue(result) : iDefault;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ public static Object foreachRecord(
for (Object inner : OMultiValue.getMultiValueIterable(o, false)) {
result.add(iCallable.call((OIdentifiable) inner));
}
} else result.add(iCallable.call((OIdentifiable) o));
} else if (o instanceof OIdentifiable) {
result.add(iCallable.call((OIdentifiable) o));
} else if (o instanceof OResult) {
return iCallable.call(((OResult) o).toElement());
}
}
return result;
} else if (iCurrent instanceof OIdentifiable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import com.orientechnologies.common.exception.OException;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.record.OElement;
import com.orientechnologies.orient.core.sql.executor.resultset.OExecutionStream;
import com.orientechnologies.orient.core.sql.parser.OFromItem;
import java.util.Collections;

/** Created by luigidellaquila on 22/07/16. */
public class FetchFromVariableStep extends AbstractExecutionStep {
Expand All @@ -34,12 +34,12 @@ public OExecutionStream internalStart(OCommandContext ctx) throws OTimeoutExcept
source =
OExecutionStream.resultIterator(((OResultSet) src).stream().iterator())
.onClose((context) -> ((OResultSet) src).close());
} else if (src instanceof ORID) {
source = OExecutionStream.singleton(new OResultInternal(ctx.getDatabase().load((ORID) src)));
} else if (src instanceof OElement) {
source =
OExecutionStream.resultIterator(
Collections.singleton((OResult) new OResultInternal((OElement) src)).iterator());
source = OExecutionStream.singleton(new OResultInternal((OElement) src));
} else if (src instanceof OResult) {
source = OExecutionStream.resultIterator(Collections.singleton((OResult) src).iterator());
source = OExecutionStream.singleton((OResult) src);
} else if (src instanceof Iterable) {
source = OExecutionStream.iterator(((Iterable) src).iterator());
} else {
Expand Down

0 comments on commit 49efc4d

Please sign in to comment.