diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OProjectionItem.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OProjectionItem.java index e0cf6fb5372..8415d20b243 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OProjectionItem.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OProjectionItem.java @@ -6,6 +6,9 @@ import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.db.record.ridbag.ORidBag; import com.orientechnologies.orient.core.exception.OCommandExecutionException; +import com.orientechnologies.orient.core.id.ORID; +import com.orientechnologies.orient.core.record.impl.OEdgeToVertexIterable; +import com.orientechnologies.orient.core.record.impl.OEdgeToVertexIterator; import com.orientechnologies.orient.core.sql.executor.AggregationContext; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultInternal; @@ -116,6 +119,16 @@ private Object convert(Object value) { ((ORidBag) value).forEach(x -> result.add(x)); return result; } + if (value instanceof OEdgeToVertexIterable) { + value = ((OEdgeToVertexIterable) value).iterator(); + } + if (value instanceof OEdgeToVertexIterator) { + List result = new ArrayList<>(); + while (((OEdgeToVertexIterator) value).hasNext()) { + result.add(((OEdgeToVertexIterator) value).next().getIdentity()); + } + return result; + } return value; } diff --git a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java index e48ad2bf0fc..bc3f9eac220 100644 --- a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java @@ -13,7 +13,6 @@ import com.orientechnologies.orient.core.record.OElement; import com.orientechnologies.orient.core.record.OVertex; import com.orientechnologies.orient.core.record.impl.ODocument; -import com.orientechnologies.orient.core.record.impl.OEdgeToVertexIterable; import com.orientechnologies.orient.core.sql.OCommandSQL; import org.junit.AfterClass; import org.junit.Assert; @@ -2166,10 +2165,10 @@ public void testLetWithTraverseFunction() { int counter = 0; while (resultSet.hasNext()) { OResult result = resultSet.next(); - OEdgeToVertexIterable edge = result.getProperty("$x"); - Iterator iter = edge.iterator(); + Iterable edge = result.getProperty("$x"); + Iterator iter = edge.iterator(); while (iter.hasNext()) { - OVertex toVertex = iter.next(); + OVertex toVertex = db.load(iter.next().getIdentity()); if (doc2Id.equals(toVertex.getIdentity())) { ++counter; }