Fix SELECT FROM INDEX from a subquery
Resolves:
@@ -13,40 +13,11 @@ import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.viewmanager.ViewManager;
import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.exception.OCommandInterruptedException;
-import com.orientechnologies.orient.core.index.OCompositeKey;
-import com.orientechnologies.orient.core.index.OIndex;
-import com.orientechnologies.orient.core.index.OIndexCursor;
-import com.orientechnologies.orient.core.index.OIndexDefinition;
-import com.orientechnologies.orient.core.index.OIndexDefinitionMultiValue;
+import com.orientechnologies.orient.core.index.*;
import com.orientechnologies.orient.core.metadata.schema.OType;
-import com.orientechnologies.orient.core.sql.parser.OAndBlock;
-import com.orientechnologies.orient.core.sql.parser.OBaseExpression;
-import com.orientechnologies.orient.core.sql.parser.OBetweenCondition;
-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.OCollection;
-import com.orientechnologies.orient.core.sql.parser.OContainsAnyCondition;
-import com.orientechnologies.orient.core.sql.parser.OContainsKeyOperator;
-import com.orientechnologies.orient.core.sql.parser.OContainsValueOperator;
-import com.orientechnologies.orient.core.sql.parser.OEqualsCompareOperator;
-import com.orientechnologies.orient.core.sql.parser.OExpression;
-import com.orientechnologies.orient.core.sql.parser.OGeOperator;
-import com.orientechnologies.orient.core.sql.parser.OGtOperator;
-import com.orientechnologies.orient.core.sql.parser.OInCondition;
-import com.orientechnologies.orient.core.sql.parser.OLeOperator;
-import com.orientechnologies.orient.core.sql.parser.OLtOperator;
-import com.orientechnologies.orient.core.sql.parser.OValueExpression;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
+import com.orientechnologies.orient.core.sql.parser.*;
+
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -297,8 +268,16 @@ public class FetchFromIndexStep extends AbstractExecutionStep {
if (OMultiValue.isMultiValue(rightValue)) {
customIterator = new OMultiCollectionIterator<>();
for (Object item : OMultiValue.getMultiValueIterable(rightValue)) {
+ if (item instanceof OResult) {
+ if (((OResult) item).isElement()) {
+ item = ((OResult) item).getElement().get();
+ } else if (((OResult) item).getPropertyNames().size() == 1) {
+ item = ((OResult) item).getProperty(((OResult) item).getPropertyNames().iterator().next());
+ }
+ }
OIndexCursor localCursor = createCursor(equals, definition, item, ctx);
+ Object item_ = item;
customIterator.add(new Iterator<Map.Entry>() {
@Override
public boolean hasNext() {
@@ -315,7 +294,7 @@ public class FetchFromIndexStep extends AbstractExecutionStep {
@Override
public Object getKey() {
- return item;
+ return item_;
}
@Override
