Skip to content

Commit

Permalink
fix: correct rid comparation in case of embedded query
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Oct 17, 2023
1 parent 15480ab commit 75c35aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> firstFieldName = iRecord.getPropertyNames();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 75c35aa

Please sign in to comment.