Skip to content

Commit

Permalink
Fix SELECT FROM INDEX from a subquery
Browse files Browse the repository at this point in the history
Resolves: #8745
  • Loading branch information
luigidellaquila committed Feb 4, 2019
1 parent 22b25b2 commit 14c27d5
Showing 1 changed file with 13 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,11 @@
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;

/**
Expand Down Expand Up @@ -297,8 +268,16 @@ private void processInCondition() {
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() {
Expand All @@ -315,7 +294,7 @@ public Map.Entry next() {

@Override
public Object getKey() {
return item;
return item_;
}

@Override
Expand Down

0 comments on commit 14c27d5

Please sign in to comment.