diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorEquals.java b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorEquals.java index 863846dd459..76e3333ad34 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorEquals.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/operator/OQueryOperatorEquals.java @@ -135,7 +135,7 @@ protected static boolean comparesValues( protected static boolean comparesValues( final Object iValue, final OResult iRecord, final boolean iConsiderIn) { if (iRecord.getIdentity().isPresent() && iRecord.getIdentity().get().isPersistent()) { - return iRecord.getIdentity().equals(iValue); + return iRecord.getIdentity().get().equals(iValue); } else { // ODOCUMENT AS RESULT OF SUB-QUERY: GET THE FIRST FIELD IF ANY Set firstFieldName = iRecord.getPropertyNames(); diff --git a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OUpdateStatementExecutionTest.java b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OUpdateStatementExecutionTest.java index e9f9e016a88..a596fa4e488 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OUpdateStatementExecutionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OUpdateStatementExecutionTest.java @@ -1,15 +1,18 @@ package com.orientechnologies.orient.core.sql.executor; import static com.orientechnologies.orient.core.sql.executor.ExecutionPlanPrintUtils.printExecutionPlan; +import static org.junit.Assert.assertEquals; import com.orientechnologies.orient.core.OCreateDatabaseUtil; import com.orientechnologies.orient.core.db.ODatabaseSession; import com.orientechnologies.orient.core.db.OrientDB; import com.orientechnologies.orient.core.db.document.ODatabaseDocument; import com.orientechnologies.orient.core.db.viewmanager.ViewCreationListener; +import com.orientechnologies.orient.core.id.ORID; import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.schema.OType; import com.orientechnologies.orient.core.metadata.schema.OViewConfig; +import com.orientechnologies.orient.core.record.OVertex; import com.orientechnologies.orient.core.record.impl.ODocument; import java.util.ArrayList; import java.util.HashMap; @@ -732,4 +735,24 @@ public void testReturnBefore() { Assert.assertFalse(result.hasNext()); result.close(); } + + @Test + public void testUpdateWhereSubquery() { + + OVertex vertex = db.newVertex(); + vertex.setProperty("one", "two"); + ORID identity = db.save(vertex).getIdentity(); + + try (OResultSet result = + db.command( + "update v set first='value' where @rid in (select @rid from [" + identity + "]) ")) { + assertEquals((long) result.next().getProperty("count"), 1L); + } + + try (OResultSet result = + db.command( + "update v set other='value' where @rid in (select * from [" + identity + "]) ")) { + assertEquals((long) result.next().getProperty("count"), 1L); + } + } }