/* Generated By:JJTree: Do not edit this line. OUpdateRemoveItem.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.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.sql.executor.OResultInternal;

import java.util.Map;

public class OUpdateRemoveItem extends SimpleNode {

  OExpression left;
  OExpression right;

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

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

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

  public void toString(Map<Object, Object> params, StringBuilder builder) {
    left.toString(params, builder);
    if (right != null) {
      builder.append(" = ");
      right.toString(params, builder);
    }
  }

  public OUpdateRemoveItem copy() {
    OUpdateRemoveItem result = new OUpdateRemoveItem(-1);
    result.left = left == null ? null : left.copy();
    result.right = right == null ? null : right.copy();
    return result;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o)
      return true;
    if (o == null || getClass() != o.getClass())
      return false;

    OUpdateRemoveItem that = (OUpdateRemoveItem) o;

    if (left != null ? !left.equals(that.left) : that.left != null)
      return false;
    if (right != null ? !right.equals(that.right) : that.right != null)
      return false;

    return true;
  }

  @Override
  public int hashCode() {
    int result = left != null ? left.hashCode() : 0;
    result = 31 * result + (right != null ? right.hashCode() : 0);
    return result;
  }

  public void applyUpdate(OResultInternal result, OCommandContext ctx) {
    if (right != null) {
      throw new OCommandExecutionException("cannot apply REMOVE " + right.toString() + " (not supported in V 3.0)");
    }
    left.applyRemove(result, ctx);
  }
}
/* JavaCC - OriginalChecksum=72e240d3dc1196fdea69e8fdc2bd69ca (do not edit this line) */

@@ -330,43 +330,37 @@
 ies.
-orient.core.command.OCommandContext
+common.collection.OMultiValue
 ;%0Aim
@@ -402,44 +402,31 @@
 ore.
-exception.OCommandExecutionException
+command.OCommandContext
 ;%0Aim
@@ -2036,125 +2036,228 @@
     
-throw new OCommandExecutionException(%22cannot apply REMOVE %22 + right.toString() + %22 (not supported in V 3.0)%22
+Object leftVal = left.execute(result, ctx);%0A      Object rightVal = right.execute(result, ctx);%0A      if (OMultiValue.isMultiValue(leftVal)) %7B%0A        OMultiValue.remove(leftVal, rightVal, false
 );%0A    
+ 
+ 
 %7D%0A
+    %7D else %7B%0A  
     
@@ -2287,16 +2287,22 @@
 , ctx);%0A
+    %7D%0A
   %7D%0A%7D%0A/*

Fix UPDATE REMOVE a = b