提交 77b776ab authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add support for standard ARRAY value constructor by enumeration

上级 ef5b09f0
......@@ -2022,11 +2022,21 @@ ID=1 AND NAME='Hi'
"
"Other Grammar","Array","
( [ expression, [ expression [,...] ] ] )
ARRAY '[' [ expression, [,...] ] ']'
| ( [ expression, [ expression [,...] ] ] )
","
An array of values. An empty array is '()'. Trailing commas are ignored.
An array with one element must contain a comma to be parsed as an array.
An array of values.
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, )
()
......
......@@ -3813,6 +3813,21 @@ public class Parser {
// Unquoted identifier is never empty
char ch = name.charAt(0);
switch (ch) {
case 'A':
case 'a':
if (equalsToken("ARRAY", name)) {
read(OPEN_BRACKET);
ArrayList<Expression> list = Utils.newSmallArrayList();
if (!readIf(CLOSE_BRACKET)) {
list.add(readExpression());
while (readIf(COMMA)) {
list.add(readExpression());
}
read(CLOSE_BRACKET);
}
return new ExpressionList(list.toArray(new Expression[0]));
}
break;
case 'C':
case 'c':
if (equalsToken("CURRENT_DATE", name)) {
......
......@@ -14,3 +14,12 @@ SELECT (10, 20, 30)[0];
SELECT (10, 20, 30)[4];
>> null
SELECT ARRAY[];
>> ()
SELECT ARRAY[10];
>> (10)
SELECT ARRAY[10, 20, 30];
>> (10, 20, 30)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论