Unverified 提交 eb3638d7 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1517 from katzyn/array

Fix array element reference and add standard array value constructor
...@@ -2022,11 +2022,21 @@ ID=1 AND NAME='Hi' ...@@ -2022,11 +2022,21 @@ ID=1 AND NAME='Hi'
" "
"Other Grammar","Array"," "Other Grammar","Array","
( [ expression, [ expression [,...] ] ] ) ARRAY '[' [ expression, [,...] ] ']'
| ( [ expression, [ expression [,...] ] ] )
"," ","
An array of values. An empty array is '()'. Trailing commas are ignored. An array of values.
An array with one element must contain a comma to be parsed as an array.
The array can be declared with standard ARRAY[] syntax or with H2 syntax.
With standard syntax trailing comma is not allowed.
With H2 syntax an empty array is '()'. Trailing comma is ignored.
An array with one element must contain a trailing comma to be parsed as an array.
"," ","
ARRAY[1, 2]
ARRAY[1]
ARRAY[]
(1, 2) (1, 2)
(1, ) (1, )
() ()
......
...@@ -21,6 +21,8 @@ Change Log ...@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Issue #1516: Array element reference array[index] should be 1-based
</li>
<li>Issue #1512: TestMVTableEngine.testLowRetentionTime(): NPE in VersionedValue.Type <li>Issue #1512: TestMVTableEngine.testLowRetentionTime(): NPE in VersionedValue.Type
</li> </li>
<li>PR #1513: Assorted minor changes <li>PR #1513: Assorted minor changes
......
...@@ -440,7 +440,7 @@ public class TestFunctions extends TestDb implements AggregateFunction { ...@@ -440,7 +440,7 @@ public class TestFunctions extends TestDb implements AggregateFunction {
stat.execute("create alias dynamic deterministic for \"" + stat.execute("create alias dynamic deterministic for \"" +
getClass().getName() + ".dynamic\""); getClass().getName() + ".dynamic\"");
setCount(0); setCount(0);
rs = stat.executeQuery("call dynamic(('a', 1))[0]"); rs = stat.executeQuery("call dynamic(('a', 1))[1]");
rs.next(); rs.next();
String a = rs.getString(1); String a = rs.getString(1);
assertEquals("a1", a); assertEquals("a1", a);
......
...@@ -2,3 +2,24 @@ ...@@ -2,3 +2,24 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
SELECT (10, 20, 30)[1];
>> 10
SELECT (10, 20, 30)[3];
>> 30
SELECT (10, 20, 30)[0];
>> null
SELECT (10, 20, 30)[4];
>> null
SELECT ARRAY[];
>> ()
SELECT ARRAY[10];
>> (10)
SELECT ARRAY[10, 20, 30];
>> (10, 20, 30)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论