예제 #1
0
    protected ModificationStatement prepareInternal(
        CFDefinition cfDef, VariableSpecifications boundNames, Attributes attrs)
        throws InvalidRequestException {
      UpdateStatement stmt = new UpdateStatement(boundNames.size(), cfDef.cfm, attrs);

      for (Pair<ColumnIdentifier, Operation.RawUpdate> entry : updates) {
        CFDefinition.Name name = cfDef.get(entry.left);
        if (name == null)
          throw new InvalidRequestException(String.format("Unknown identifier %s", entry.left));

        Operation operation = entry.right.prepare(name);
        operation.collectMarkerSpecification(boundNames);

        switch (name.kind) {
          case KEY_ALIAS:
          case COLUMN_ALIAS:
            throw new InvalidRequestException(
                String.format("PRIMARY KEY part %s found in SET part", entry.left));
          case VALUE_ALIAS:
          case COLUMN_METADATA:
            stmt.addOperation(operation);
            break;
        }
      }

      stmt.processWhereClause(whereClause, boundNames);
      return stmt;
    }