diff --git a/core/src/main/java/com/orientechnologies/orient/core/record/impl/OEdgeDelegate.java b/core/src/main/java/com/orientechnologies/orient/core/record/impl/OEdgeDelegate.java index 0de621f7f19..832c41d162e 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/record/impl/OEdgeDelegate.java +++ b/core/src/main/java/com/orientechnologies/orient/core/record/impl/OEdgeDelegate.java @@ -503,8 +503,8 @@ public String toJSON() { if (element != null) { return element.toJSON(); } else { - return "{'out':'" + vOut.getIdentity() + "', 'in':'" + vIn.getIdentity() + "', '@class':'" + OStringSerializerHelper - .encode(lightweightEdgeType.getName()) + "'}"; + return "{\"out\":\"" + vOut.getIdentity() + "\", \"in\":\"" + vIn.getIdentity() + "\", \"@class\":\"" + OStringSerializerHelper + .encode(lightweightEdgeType.getName()) + "\"}"; } } @@ -513,8 +513,8 @@ public String toJSON(String iFormat) { if (element != null) { return element.toJSON(iFormat); } else { - return "{'out':'" + vOut.getIdentity() + "', 'in':'" + vIn.getIdentity() + "', '@class':'" + OStringSerializerHelper - .encode(lightweightEdgeType.getName()) + "'}"; + return "{\"out\":\"" + vOut.getIdentity() + "\", \"in\":\"" + vIn.getIdentity() + "\", \"@class\":\"" + OStringSerializerHelper + .encode(lightweightEdgeType.getName()) + "\"}"; } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/executor/OSelectExecutionPlanner.java b/core/src/main/java/com/orientechnologies/orient/core/sql/executor/OSelectExecutionPlanner.java index 3851fe241fe..49c3da30971 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/executor/OSelectExecutionPlanner.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/executor/OSelectExecutionPlanner.java @@ -16,61 +16,9 @@ import com.orientechnologies.orient.core.metadata.schema.OProperty; import com.orientechnologies.orient.core.metadata.schema.OType; import com.orientechnologies.orient.core.sql.OCommandExecutorSQLAbstract; -import com.orientechnologies.orient.core.sql.parser.AggregateProjectionSplit; -import com.orientechnologies.orient.core.sql.parser.OAndBlock; -import com.orientechnologies.orient.core.sql.parser.OBaseExpression; -import com.orientechnologies.orient.core.sql.parser.OBinaryCompareOperator; -import com.orientechnologies.orient.core.sql.parser.OBinaryCondition; -import com.orientechnologies.orient.core.sql.parser.OBooleanExpression; -import com.orientechnologies.orient.core.sql.parser.OCluster; -import com.orientechnologies.orient.core.sql.parser.OContainsAnyCondition; -import com.orientechnologies.orient.core.sql.parser.OContainsKeyOperator; -import com.orientechnologies.orient.core.sql.parser.OContainsValueCondition; -import com.orientechnologies.orient.core.sql.parser.OContainsValueOperator; -import com.orientechnologies.orient.core.sql.parser.OEqualsCompareOperator; -import com.orientechnologies.orient.core.sql.parser.OExecutionPlanCache; -import com.orientechnologies.orient.core.sql.parser.OExpression; -import com.orientechnologies.orient.core.sql.parser.OFromClause; -import com.orientechnologies.orient.core.sql.parser.OFromItem; -import com.orientechnologies.orient.core.sql.parser.OFunctionCall; -import com.orientechnologies.orient.core.sql.parser.OGeOperator; -import com.orientechnologies.orient.core.sql.parser.OGroupBy; -import com.orientechnologies.orient.core.sql.parser.OGtOperator; -import com.orientechnologies.orient.core.sql.parser.OIdentifier; -import com.orientechnologies.orient.core.sql.parser.OInCondition; -import com.orientechnologies.orient.core.sql.parser.OIndexIdentifier; -import com.orientechnologies.orient.core.sql.parser.OInputParameter; -import com.orientechnologies.orient.core.sql.parser.OInteger; -import com.orientechnologies.orient.core.sql.parser.OLeOperator; -import com.orientechnologies.orient.core.sql.parser.OLetClause; -import com.orientechnologies.orient.core.sql.parser.OLetItem; -import com.orientechnologies.orient.core.sql.parser.OLtOperator; -import com.orientechnologies.orient.core.sql.parser.OMetadataIdentifier; -import com.orientechnologies.orient.core.sql.parser.OOrBlock; -import com.orientechnologies.orient.core.sql.parser.OOrderBy; -import com.orientechnologies.orient.core.sql.parser.OOrderByItem; -import com.orientechnologies.orient.core.sql.parser.OProjection; -import com.orientechnologies.orient.core.sql.parser.OProjectionItem; -import com.orientechnologies.orient.core.sql.parser.ORecordAttribute; -import com.orientechnologies.orient.core.sql.parser.ORid; -import com.orientechnologies.orient.core.sql.parser.OSelectStatement; -import com.orientechnologies.orient.core.sql.parser.OStatement; -import com.orientechnologies.orient.core.sql.parser.OWhereClause; -import com.orientechnologies.orient.core.sql.parser.SubQueryCollector; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import com.orientechnologies.orient.core.sql.parser.*; + +import java.util.*; import java.util.stream.Collectors; /** @@ -811,6 +759,7 @@ private static List calculateAdditionalOrderByProjections(Set 0 ? 1 : -1; } } return 0; @@ -69,7 +69,8 @@ public OOrderBy 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()) @@ -83,22 +84,23 @@ public OOrderBy copy() { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { return items != null ? items.hashCode() : 0; } public void extractSubQueries(SubQueryCollector collector) { - if(items!=null){ - for(OOrderByItem item:items){ + if (items != null) { + for (OOrderByItem item : items) { item.extractSubQueries(collector); } } } public boolean refersToParent() { - if(items!=null){ - for(OOrderByItem item:items){ - if(item.refersToParent()){ + if (items != null) { + for (OOrderByItem item : items) { + if (item.refersToParent()) { return true; } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OOrderByItem.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OOrderByItem.java index 1b5ea5e3499..b81e298ffc0 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OOrderByItem.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OOrderByItem.java @@ -93,11 +93,9 @@ public int compare(OResult a, OResult b, OCommandContext ctx) { } else { result = -1; } - } - if (bVal == null) { + } else if (bVal == null) { result = 1; - } - if (aVal instanceof Comparable && bVal instanceof Comparable) { + } else if (aVal instanceof Comparable && bVal instanceof Comparable) { try { result = ((Comparable) aVal).compareTo(bVal); } catch (Exception e) { @@ -141,6 +139,10 @@ public OModifier getModifier() { return modifier; } + public void setModifier(OModifier modifier) { + this.modifier = modifier; + } + public OResult serialize() { OResultInternal result = new OResultInternal(); result.setProperty("alias", alias); diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/OHttpGraphResponse.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/OHttpGraphResponse.java index 79eef13aaef..636a5b1c58d 100755 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/OHttpGraphResponse.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/OHttpGraphResponse.java @@ -128,9 +128,9 @@ public void writeRecords(final Object iRecords, final String iFetchPlan, String json.beginCollection("edges"); Set edgeRids = new HashSet(); for (OVertex vertex : vertices) { - for (OEdge e : vertex.getEdges(ODirection.BOTH)) { + for (OEdge e : vertex.getEdges(ODirection.OUT)) { OEdge edge = (OEdge) e; - if (edgeRids.contains(e.getIdentity())) { + if (edgeRids.contains(e.getIdentity()) && e.getIdentity() != null /* only for non-lighweight */) { continue; } if (!vertices.contains(edge.getVertex(ODirection.OUT)) || !vertices.contains(edge.getVertex(ODirection.IN)))