}
return filter.getTable().getColumn(columnName);
}
private Update parseUpdate() {
Update command = createUpdate(session);
currentPrepared = command;
int start = lastParseIndex;
TableFilter filter = readSimpleTableFilter();
command.setTableFilter(filter);
read("SET");
if (readIf("(")) {
ArrayList<Column> columns = New.arrayList();
do {
Column column = readTableColumn(filter);
columns.add(column);
} while (readIf(","));
read(")");
read("=");
Expression expression = readExpression();
if (columns.size() == 1) {
// the expression is parsed as a simple value
command.setAssignment(columns.get(0), expression);
} else {
for (int i = 0, size = columns.size(); i < size; i++) {
Column column = columns.get(i);
Function f = Function.getFunction(database, "ARRAY_GET");
f.setParameter(0, expression);
f.setParameter(1, ValueExpression.get(ValueInt.get(i + 1)));
f.doneWithParameters();
command.setAssignment(column, f);
}
}
} else {
do {
Column column = readTableColumn(filter);
read("=");
Expression expression;
if (readIf("DEFAULT")) {
expression = ValueExpression.getDefault();
} else {
expression = readExpression();
}
command.setAssignment(column, expression);
} while (readIf(","));
}
if (readIf("WHERE")) {
Expression condition = readExpression();
command.setCondition(condition);
}
if (readIf("LIMIT")) {
Expression limit = readTerm().optimize(session);
command.setLimit(limit);
}
setSQL(command, "UPDATE", start);
return command;
}