diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OTraverseProjectionItem.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OTraverseProjectionItem.java index 02354b4d34a..f9e70f71ead 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OTraverseProjectionItem.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OTraverseProjectionItem.java @@ -40,6 +40,16 @@ private boolean isStar() { return base.toString().equals("*") && modifier == null; } + public boolean refersToParent() { + if (base != null && base.refersToParent()) { + return true; + } + if (modifier != null && modifier.refersToParent()) { + return true; + } + return false; + } + private Object handleStar(OResult iCurrentRecord, OCommandContext ctx) { Set result = new HashSet<>(); for (String prop : iCurrentRecord.getPropertyNames()) { @@ -101,7 +111,8 @@ public OTraverseProjectionItem copy() { return result; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) @@ -117,7 +128,8 @@ public OTraverseProjectionItem copy() { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = (base != null ? base.hashCode() : 0); result = 31 * result + (modifier != null ? modifier.hashCode() : 0); return result; diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OTraverseStatement.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OTraverseStatement.java index c8f0dceba14..90b8bbfa261 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OTraverseStatement.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OTraverseStatement.java @@ -142,6 +142,19 @@ public void toString(Map params, StringBuilder builder) { } + public boolean refersToParent() { + if (projections != null && projections.stream().anyMatch(x -> x.refersToParent())) { + return true; + } + if (this.target != null && this.target.refersToParent()) { + return true; + } + if (this.whileClause != null && this.whileClause.refersToParent()) { + return true; + } + return false; + } + @Override public OStatement copy() { OTraverseStatement result = new OTraverseStatement(-1);