<commit_before>/* Generated By:JJTree: Do not edit this line. OContainsAllCondition.java Version 4.3 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;

import com.orientechnologies.common.collection.OMultiValue;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.sql.executor.OResult;

import java.util.*;

public class OContainsAllCondition extends OBooleanExpression {

  protected OExpression left;

  protected OExpression right;

  protected OOrBlock rightBlock;

  public OContainsAllCondition(int id) {
    super(id);
  }

  public OContainsAllCondition(OrientSql p, int id) {
    super(p, id);
  }

  /**
   * Accept the visitor.
   **/
  public Object jjtAccept(OrientSqlVisitor visitor, Object data) {
    return visitor.visit(this, data);
  }

  public boolean execute(Object left, Object right) {
    if (left instanceof Collection) {
      if (right instanceof Collection) {
        return ((Collection) left).containsAll((Collection) right);
      }
      if (right instanceof Iterable) {
        right = ((Iterable) right).iterator();
      }
      if (right instanceof Iterator) {
        Iterator iterator = (Iterator) right;
        while (iterator.hasNext()) {
          Object next = iterator.next();
          if (!((Collection) left).contains(next)) {
            return false;
          }
        }
      }
      return ((Collection) left).contains(right);
    }
    if (left instanceof Iterable) {
      left = ((Iterable) left).iterator();<commit_msg>Fix CONTAINSALL to work with subqueries<commit_after>/* Generated By:JJTree: Do not edit this line. OContainsAllCondition.java Version 4.3 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;

import com.orientechnologies.common.collection.OMultiValue;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.sql.executor.OResult;

import java.util.*;

public class OContainsAllCondition extends OBooleanExpression {

  protected OExpression left;

  protected OExpression right;

  protected OOrBlock rightBlock;

  public OContainsAllCondition(int id) {
    super(id);
  }

  public OContainsAllCondition(OrientSql p, int id) {
    super(p, id);
  }

  /**
   * Accept the visitor.
   **/
  public Object jjtAccept(OrientSqlVisitor visitor, Object data) {
    return visitor.visit(this, data);
  }

  public boolean execute(Object left, Object right) {
    if (left instanceof Collection) {
      if (right instanceof Collection) {
        if (((Collection) left).containsAll((Collection) right)) {
          return true;
        }
      }
      if (right instanceof Iterable) {
        right = ((Iterable) right).iterator();
      }
      if (right instanceof Iterator) {
        Iterator iterator = (Iterator) right;
        while (iterator.hasNext()) {
          Object next = iterator.next();
          boolean found = false;
          if (((Collection) left).contains(next)) {
            found = true;
          } else if (next instanceof OResult && ((OResult) next).isElement() && ((Collection) left).contains(((OResult) next).toElement())) {
            found = true;
          }
          if (!found) {
            return false;
          }
        }
        return true;
      }
      return ((Collection) left).contains(right);
    }
    if (left instanceof Iterable) {
      left = ((Iterable) left).iterator();
{'fraction_non_alphanumeric': 0.11085331270946121, 'fraction_numerical': 0.0010311936065996391, 'mean_word_length': 3.3255295429208473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6820951', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1121, 'n_words': 255}