提交 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,6 +671,10 @@ public class Parser { ...@@ -671,6 +671,10 @@ public class Parser {
read(")"); read(")");
read("="); read("=");
Expression expression = readExpression(); 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++) { for (int i = 0, size = columns.size(); i < size; i++) {
Column column = columns.get(i); Column column = columns.get(i);
Function f = Function.getFunction(database, "ARRAY_GET"); Function f = Function.getFunction(database, "ARRAY_GET");
...@@ -679,6 +683,7 @@ public class Parser { ...@@ -679,6 +683,7 @@ public class Parser {
f.doneWithParameters(); f.doneWithParameters();
command.setAssignment(column, f); command.setAssignment(column, f);
} }
}
} else { } else {
do { do {
Column column = readTableColumn(filter); Column column = readTableColumn(filter);
......
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论