提交 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 ...@@ -19,7 +19,9 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <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>Issue 334: SimpleResultSet.getString now also works for Clob columns.
</li><li>Subqueries with an aggregate did not always work. Example: </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 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 { ...@@ -671,13 +671,18 @@ public class Parser {
read(")"); read(")");
read("="); read("=");
Expression expression = readExpression(); Expression expression = readExpression();
for (int i = 0, size = columns.size(); i < size; i++) { if (columns.size() == 1) {
Column column = columns.get(i); // the expression is parsed as a simple value
Function f = Function.getFunction(database, "ARRAY_GET"); command.setAssignment(columns.get(0), expression);
f.setParameter(0, expression); } else {
f.setParameter(1, ValueExpression.get(ValueInt.get(i + 1))); for (int i = 0, size = columns.size(); i < size; i++) {
f.doneWithParameters(); Column column = columns.get(i);
command.setAssignment(column, f); 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 { } else {
do { do {
......
...@@ -91,6 +91,9 @@ create table test(id int primary key, name varchar(255), row_number int); ...@@ -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); insert into test values(1, 'hello', 10), (2, 'world', 20);
> update count: 2 > update count: 2
update test set (id)=(id);
> update count: 2
select row_number() over(), id, name from test order by id; select row_number() over(), id, name from test order by id;
> ROWNUM() ID NAME > ROWNUM() ID NAME
> -------- -- ----- > -------- -- -----
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论