提交 f12d1814 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Return NULL from ARRAY_CONTAINS(NULL, value) for better compatibility

上级 7296752c
...@@ -4155,7 +4155,7 @@ ISO_YEAR(CREATED) ...@@ -4155,7 +4155,7 @@ ISO_YEAR(CREATED)
ARRAY_GET(arrayExpression, indexExpression) ARRAY_GET(arrayExpression, indexExpression)
"," ","
Returns one element of an array. Returns one element of an array.
This method returns a string. Returns NULL if there is no such element or array is NULL.
"," ","
CALL ARRAY_GET(('Hello', 'World'), 2) CALL ARRAY_GET(('Hello', 'World'), 2)
" "
...@@ -4164,6 +4164,7 @@ CALL ARRAY_GET(('Hello', 'World'), 2) ...@@ -4164,6 +4164,7 @@ CALL ARRAY_GET(('Hello', 'World'), 2)
ARRAY_LENGTH(arrayExpression) ARRAY_LENGTH(arrayExpression)
"," ","
Returns the length of an array. Returns the length of an array.
Returns NULL if the specified array is NULL.
"," ","
CALL ARRAY_LENGTH(('Hello', 'World')) CALL ARRAY_LENGTH(('Hello', 'World'))
" "
...@@ -4171,7 +4172,8 @@ CALL ARRAY_LENGTH(('Hello', 'World')) ...@@ -4171,7 +4172,8 @@ CALL ARRAY_LENGTH(('Hello', 'World'))
"Functions (System)","ARRAY_CONTAINS"," "Functions (System)","ARRAY_CONTAINS","
ARRAY_CONTAINS(arrayExpression, value) ARRAY_CONTAINS(arrayExpression, value)
"," ","
Returns a boolean true if the array contains the value. Returns a boolean TRUE if the array contains the value or FALSE if it does not contain it.
Returns NULL if the specified array is NULL.
"," ","
CALL ARRAY_CONTAINS(('Hello', 'World'), 'Hello') CALL ARRAY_CONTAINS(('Hello', 'World'), 'Hello')
" "
......
...@@ -414,7 +414,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -414,7 +414,7 @@ public class Function extends Expression implements FunctionCall {
addFunctionNotDeterministic("CURRVAL", CURRVAL, addFunctionNotDeterministic("CURRVAL", CURRVAL,
VAR_ARGS, Value.LONG); VAR_ARGS, Value.LONG);
addFunction("ARRAY_GET", ARRAY_GET, addFunction("ARRAY_GET", ARRAY_GET,
2, Value.STRING); 2, Value.NULL);
addFunction("ARRAY_CONTAINS", ARRAY_CONTAINS, addFunction("ARRAY_CONTAINS", ARRAY_CONTAINS,
2, Value.BOOLEAN, false, true, true); 2, Value.BOOLEAN, false, true, true);
addFunction("CSVREAD", CSVREAD, addFunction("CSVREAD", CSVREAD,
...@@ -1059,6 +1059,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -1059,6 +1059,8 @@ public class Function extends Expression implements FunctionCall {
break; break;
} }
} }
} else {
result = ValueNull.INSTANCE;
} }
break; break;
} }
......
...@@ -22,7 +22,7 @@ select array_contains((null, 'two'), null); ...@@ -22,7 +22,7 @@ select array_contains((null, 'two'), null);
>> TRUE >> TRUE
select array_contains(null, 'one'); select array_contains(null, 'one');
>> FALSE >> null
select array_contains(((1, 2), (3, 4)), (1, 2)); select array_contains(((1, 2), (3, 4)), (1, 2));
>> TRUE >> TRUE
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论