提交 5638afc9 authored 作者: Thomas Mueller's avatar Thomas Mueller

Update statements with a column list in brackets did not work if the list only contains one column.

上级 acfe0d8d
......@@ -19,7 +19,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Read-only databases in a zip file did not work when using the -baseDir option.
<ul><li>Update statements with a column list in brackets did not work if the list only contains one column.
Example: update test set (id)=(id).
</li><li>Read-only databases in a zip file did not work when using the -baseDir option.
</li><li>Issue 334: SimpleResultSet.getString now also works for Clob columns.
</li><li>Subqueries with an aggregate did not always work. Example:
select (select count(*) from test where a = t.a and b = 0) from test t group by a
......
......@@ -671,13 +671,18 @@ public class Parser {
read(")");
read("=");
Expression expression = readExpression();
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);
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 {
......
......@@ -91,6 +91,9 @@ create table test(id int primary key, name varchar(255), row_number int);
insert into test values(1, 'hello', 10), (2, 'world', 20);
> update count: 2
update test set (id)=(id);
> update count: 2
select row_number() over(), id, name from test order by id;
> ROWNUM() ID NAME
> -------- -- -----
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论