提交 4b88dc6d authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use Value.convertTo() with TypeInfo in more places

上级 56a9668f
......@@ -99,11 +99,10 @@ public class BinaryOperation extends Expression {
@Override
public Value getValue(Session session) {
Mode mode = session.getDatabase().getMode();
int dataType = type.getValueType();
Value l = left.getValue(session).convertTo(dataType, mode);
Value l = left.getValue(session).convertTo(type, mode, null);
Value r = right.getValue(session);
if (convertRight) {
r = r.convertTo(dataType, mode);
r = r.convertTo(type, mode, null);
}
switch (opType) {
case CONCAT: {
......
......@@ -34,7 +34,7 @@ public class UnaryOperation extends Expression {
@Override
public Value getValue(Session session) {
Value a = arg.getValue(session).convertTo(type.getValueType(), session.getDatabase().getMode());
Value a = arg.getValue(session).convertTo(type, session.getDatabase().getMode(), null);
return a == ValueNull.INSTANCE ? a : a.negate();
}
......
......@@ -19,6 +19,7 @@ import org.h2.result.ResultInterface;
import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter;
import org.h2.util.StringUtils;
import org.h2.value.TypeInfo;
import org.h2.value.Value;
import org.h2.value.ValueBoolean;
import org.h2.value.ValueNull;
......@@ -72,8 +73,8 @@ public class ConditionInSelect extends Condition {
return ValueBoolean.TRUE;
}
} else {
int dataType = rows.getColumnType(0).getValueType();
if (dataType == Value.NULL) {
TypeInfo colType = rows.getColumnType(0);
if (colType.getValueType() == Value.NULL) {
return ValueBoolean.FALSE;
}
if (l.getValueType() == Value.ROW) {
......@@ -83,7 +84,7 @@ public class ConditionInSelect extends Condition {
}
l = leftList[0];
}
l = l.convertTo(dataType, database.getMode());
l = l.convertTo(colType, database.getMode(), null);
if (rows.containsDistinct(new Value[] { l })) {
return ValueBoolean.TRUE;
}
......
......@@ -97,10 +97,10 @@ public class HashIndex extends BaseIndex {
/*
* Sometimes the incoming search is a similar, but not the same type
* e.g. the search value is INT, but the index column is LONG. In which
* case we need to convert, otherwise the ValueHashMap will not find the
* case we need to convert, otherwise the HashMap will not find the
* result.
*/
v = v.convertTo(tableData.getColumn(indexColumn).getType().getValueType(), database.getMode());
v = v.convertTo(tableData.getColumn(indexColumn).getType(), database.getMode(), null);
Row result;
Long pos = rows.get(v);
if (pos == null) {
......
......@@ -105,10 +105,10 @@ public class NonUniqueHashIndex extends BaseIndex {
/*
* Sometimes the incoming search is a similar, but not the same type
* e.g. the search value is INT, but the index column is LONG. In which
* case we need to convert, otherwise the ValueHashMap will not find the
* case we need to convert, otherwise the HashMap will not find the
* result.
*/
v = v.convertTo(tableData.getColumn(indexColumn).getType().getValueType(), database.getMode());
v = v.convertTo(tableData.getColumn(indexColumn).getType(), database.getMode(), null);
ArrayList<Long> positions = rows.get(v);
return new NonUniqueHashCursor(session, tableData, positions);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论