提交 18130ce9 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix ConditionInSelect with 1-element row on the left side

上级 2d258d66
......@@ -5,6 +5,7 @@
*/
package org.h2.expression.condition;
import org.h2.api.ErrorCode;
import org.h2.command.dml.Query;
import org.h2.engine.Database;
import org.h2.engine.Session;
......@@ -12,6 +13,7 @@ import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn;
import org.h2.expression.ExpressionVisitor;
import org.h2.index.IndexCondition;
import org.h2.message.DbException;
import org.h2.result.LocalResult;
import org.h2.result.ResultInterface;
import org.h2.table.ColumnResolver;
......@@ -74,6 +76,13 @@ public class ConditionInSelect extends Condition {
if (dataType == Value.NULL) {
return ValueBoolean.FALSE;
}
if (l.getType() == Value.ROW) {
Value[] leftList = ((ValueRow) l).getList();
if (leftList.length != 1) {
throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
}
l = leftList[0];
}
l = l.convertTo(dataType, database.getMode());
if (rows.containsDistinct(new Value[] { l })) {
return ValueBoolean.TRUE;
......
......@@ -72,8 +72,17 @@ CREATE TABLE TEST(A ARRAY);
INSERT INTO TEST VALUES (ARRAY[1, NULL]), (ARRAY[1, 2]);
> update count: 2
SELECT ARRAY[1, 2] IN (SELECT A FROM TEST);
>> TRUE
SELECT ROW (ARRAY[1, 2]) IN (SELECT A FROM TEST);
>> TRUE
SELECT ARRAY[1, NULL] IN (SELECT A FROM TEST);
>> null
SELECT ROW (ARRAY[1, NULL]) IN (SELECT A FROM TEST);
>> null
DROP TABLE TEST;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论