Skip to content

Commit

Permalink
Fix subqueries with indexes
Browse files Browse the repository at this point in the history
Refers to: #8528
  • Loading branch information
luigidellaquila committed Sep 12, 2018
1 parent 2ada36e commit 44cd7ac
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
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.*;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.sql.parser.*;

Expand Down Expand Up @@ -345,14 +342,23 @@ private void init(OCollection fromKey, boolean fromKeyIncluded, OCollection toKe
List<OCollection> secondValueCombinations = cartesianProduct(fromKey);
List<OCollection> thirdValueCombinations = cartesianProduct(toKey);

OIndexDefinition indexDef = index.getDefinition();

for (int i = 0; i < secondValueCombinations.size(); i++) {

Object secondValue = secondValueCombinations.get(i).execute((OResult) null, ctx);
if (secondValue instanceof List && ((List) secondValue).size() == 1 && indexDef.getFields().size() == 1
&& !(indexDef instanceof OIndexDefinitionMultiValue)) {
secondValue = ((List) secondValue).get(0);
}
secondValue = unboxOResult(secondValue);
Object thirdValue = thirdValueCombinations.get(i).execute((OResult) null, ctx);
if (thirdValue instanceof List && ((List) thirdValue).size() == 1 && indexDef.getFields().size() == 1
&& !(indexDef instanceof OIndexDefinitionMultiValue)) {
thirdValue = ((List) thirdValue).get(0);
}
thirdValue = unboxOResult(thirdValue);

OIndexDefinition indexDef = index.getDefinition();
try {
secondValue = convertToIndexDefinitionTypes(secondValue, indexDef.getTypes());
thirdValue = convertToIndexDefinitionTypes(thirdValue, indexDef.getTypes());
Expand Down

0 comments on commit 44cd7ac

Please sign in to comment.