Fix error; clarify more results in test

This commit is contained in:
Alexey Milovidov 2020-06-14 02:27:10 +03:00
parent 4024840795
commit e2f7a41a1a
3 changed files with 29 additions and 2 deletions

View File

@ -817,6 +817,7 @@ private:
const DataTypePtr & left_type, const DataTypePtr & right_type, size_t input_rows_count)
{
/// To compare something with const string, we cast constant to appropriate type and compare as usual.
/// It is ok to throw exception if value is not convertible.
/// We should deal with possible overflows, e.g. toUInt8(1) = '257' should return false.
const ColumnConst * left_const = checkAndGetColumnConstStringOrFixedString(col_left_untyped);
@ -831,10 +832,11 @@ private:
Field string_value = left_const ? left_const->getField() : right_const->getField();
Field converted = convertFieldToType(string_value, *type_to_compare, type_string);
/// If not possible to convert, comparison yields to false.
/// If not possible to convert, comparison with =, <, >, <=, >= yields to false and comparison with != yields to true.
if (converted.isNull())
{
block.getByPosition(result).column = DataTypeUInt8().createColumnConst(input_rows_count, 0);
block.getByPosition(result).column = DataTypeUInt8().createColumnConst(input_rows_count,
std::is_same_v<Op<int, int>, NotEqualsOp<int, int>>);
}
else
{

View File

@ -16,5 +16,17 @@
0
---
---
0
---
1
---
0
---
0
---
0
---
0
---
1
---

View File

@ -14,6 +14,19 @@ SELECT '---';
SELECT 1 = '1.0'; -- { serverError 131 }
SELECT '---';
SELECT 1 = '257';
SELECT '---';
SELECT 1 != '257';
SELECT '---';
SELECT 1 < '257'; -- this is wrong for now
SELECT '---';
SELECT 1 > '257';
SELECT '---';
SELECT 1 <= '257'; -- this is wrong for now
SELECT '---';
SELECT 1 >= '257';
SELECT '---';
SELECT toDateTime('2020-06-13 01:02:03') = '2020-06-13T01:02:03';
SELECT '---';