提交 6f2686c4 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix single-column row value expressions in UPDATE command

上级 764384ed
...@@ -2597,11 +2597,13 @@ COMPRESSION LZF ...@@ -2597,11 +2597,13 @@ COMPRESSION LZF
"Other Grammar","Row value expression"," "Other Grammar","Row value expression","
ROW (expression, [,...]) ROW (expression, [,...])
| ( [ expression, expression [,...] ] ) | ( [ expression, expression [,...] ] )
| expression
"," ","
A row value expression. A row value expression.
"," ","
ROW (1) ROW (1)
(1, 2) (1, 2)
1
" "
"Other Grammar","Select Expression"," "Other Grammar","Select Expression","
......
...@@ -1175,7 +1175,7 @@ public class Parser { ...@@ -1175,7 +1175,7 @@ public class Parser {
} while (readIfMore(true)); } while (readIfMore(true));
read(EQUAL); read(EQUAL);
Expression expression = readExpression(); Expression expression = readExpression();
if (columns.size() == 1) { if (columns.size() == 1 && expression.getType().getValueType() != Value.ROW) {
// the expression is parsed as a simple value // the expression is parsed as a simple value
command.setAssignment(columns.get(0), expression); command.setAssignment(columns.get(0), expression);
} else { } else {
......
...@@ -158,7 +158,7 @@ public class TestScript extends TestDb { ...@@ -158,7 +158,7 @@ public class TestScript extends TestDb {
testScript("ddl/" + s + ".sql"); testScript("ddl/" + s + ".sql");
} }
for (String s : new String[] { "delete", "error_reporting", "insert", "insertIgnore", "merge", "mergeUsing", for (String s : new String[] { "delete", "error_reporting", "insert", "insertIgnore", "merge", "mergeUsing",
"replace", "script", "select", "show", "table", "values", "with" }) { "replace", "script", "select", "show", "table", "update", "values", "with" }) {
testScript("dml/" + s + ".sql"); testScript("dml/" + s + ".sql");
} }
for (String s : new String[] { "help" }) { for (String s : new String[] { "help" }) {
......
-- Copyright 2004-2019 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE TABLE TEST(A INT, B INT);
> ok
INSERT INTO TEST VALUES (1, 2);
> update count: 1
UPDATE TEST SET (A, B) = (3, 4);
> update count: 1
SELECT * FROM TEST;
> A B
> - -
> 3 4
> rows: 1
UPDATE TEST SET (B) = 5;
> update count: 1
SELECT B FROM TEST;
>> 5
UPDATE TEST SET (B) = ROW (6);
> update count: 1
SELECT B FROM TEST;
>> 6
UPDATE TEST SET (B) = (7);
> update count: 1
SELECT B FROM TEST;
>> 7
DROP TABLE TEST;
> ok
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
select * from table(a int=(1)), table(b int=(2)); select * from table(a int=(1)), table(b int=2), table(c int=row(3));
> A B > A B C
> - - > - - -
> 1 2 > 1 2 3
> rows: 1 > rows: 1
create table test as select * from table(id int=(1, 2, 3)); create table test as select * from table(id int=(1, 2, 3));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论