Skip to content

Commit

Permalink
Fix UPDATE EDGE with subqueries
Browse files Browse the repository at this point in the history
Resolves: #8406
  • Loading branch information
luigidellaquila committed Jul 17, 2018
1 parent be3283d commit 2fdb9b1
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.record.impl.ODocument;

import java.util.Collection;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -83,6 +84,16 @@ private void handleUpdateEdge(ODocument record) {
Object prevOut = record.getOriginalValue("out");
Object prevIn = record.getOriginalValue("in");

// to manage subqueries
if (currentOut instanceof Collection && ((Collection) currentOut).size() == 1) {
currentOut = ((Collection) currentOut).iterator().next();
record.setProperty("out", currentOut);
}
if (currentIn instanceof Collection && ((Collection) currentIn).size() == 1) {
currentIn = ((Collection) currentIn).iterator().next();
record.setProperty("in", currentIn);
}

validateOutInForEdge(record, currentOut, currentIn);

changeVertexEdgePointer(record, (OIdentifiable) prevIn, (OIdentifiable) currentIn, "in");
Expand Down

0 comments on commit 2fdb9b1

Please sign in to comment.