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

Fix convertScale() and equals() in ValueInterval

上级 24061850
......@@ -3562,7 +3562,11 @@ public class Parser {
read("SECOND");
qualifier = IntervalQualifier.SECOND;
}
r = ValueExpression.get(DateTimeUtils.parseInterval(qualifier, negative, s));
try {
r = ValueExpression.get(DateTimeUtils.parseInterval(qualifier, negative, s));
} catch (Exception e) {
throw DbException.get(ErrorCode.INVALID_DATETIME_CONSTANT_2, e, "INTERVAL", s);
}
} else if (currentTokenType == VALUE &&
currentValue.getType() == Value.STRING) {
if (equalsToken("DATE", name) ||
......
......@@ -129,7 +129,7 @@ public class ValueInterval extends Value {
}
break;
}
return from(qualifier, l, r);
return from(qualifier, negative ? -l : l, r);
}
@Override
......@@ -201,7 +201,7 @@ public class ValueInterval extends Value {
return false;
}
ValueInterval other = (ValueInterval) obj;
return type == other.type && leading == other.leading || remaining == other.remaining;
return type == other.type && leading == other.leading && remaining == other.remaining;
}
@Override
......
......@@ -75,23 +75,23 @@ INSERT INTO TEST VALUES (
SELECT I01, I02, I03, I04, I05, I06 FROM TEST ORDER BY ID;
> I01 I02 I03 I04 I05 I06
> ------------------ ------------------- ----------------- ------------------ -------------------- --------------------------
> ------------------ ------------------- ----------------- ------------------ -------------------- ---------------------------
> INTERVAL '1' YEAR INTERVAL '1' MONTH INTERVAL '1' DAY INTERVAL '1' HOUR INTERVAL '1' MINUTE INTERVAL '1.123457' SECOND
> INTERVAL '-1' YEAR INTERVAL '-1' MONTH INTERVAL '-1' DAY INTERVAL '-1' HOUR INTERVAL '-1' MINUTE INTERVAL '1.123457' SECOND
> INTERVAL '-1' YEAR INTERVAL '-1' MONTH INTERVAL '-1' DAY INTERVAL '-1' HOUR INTERVAL '-1' MINUTE INTERVAL '-1.123457' SECOND
> rows (ordered): 2
SELECT I07, I08, I09, I10 FROM TEST ORDER BY ID;
> I07 I08 I09 I10
> ----------------------------- ---------------------------- --------------------------------- ------------------------------------------
> ----------------------------- ---------------------------- --------------------------------- -------------------------------------------
> INTERVAL '1-2' YEAR TO MONTH INTERVAL '1 02' DAY TO HOUR INTERVAL '1 02:03' DAY TO MINUTE INTERVAL '1 02:03:04.123457' DAY TO SECOND
> INTERVAL '-1-2' YEAR TO MONTH INTERVAL '-1 02' DAY TO HOUR INTERVAL '-1 02:03' DAY TO MINUTE INTERVAL '1 02:03:04.123457' DAY TO SECOND
> INTERVAL '-1-2' YEAR TO MONTH INTERVAL '-1 02' DAY TO HOUR INTERVAL '-1 02:03' DAY TO MINUTE INTERVAL '-1 02:03:04.123457' DAY TO SECOND
> rows (ordered): 2
SELECT I11, I12, I12 FROM TEST ORDER BY ID;
> I11 I12 I12
> ------------------------------- ---------------------------------------- ----------------------------------------
> INTERVAL '1:02' HOUR TO MINUTE INTERVAL '1:02:03.123457' HOUR TO SECOND INTERVAL '1:02:03.123457' HOUR TO SECOND
> INTERVAL '-1:02' HOUR TO MINUTE INTERVAL '1:02:03.123457' HOUR TO SECOND INTERVAL '1:02:03.123457' HOUR TO SECOND
> I11 I12 I12
> ------------------------------- ----------------------------------------- -----------------------------------------
> INTERVAL '1:02' HOUR TO MINUTE INTERVAL '1:02:03.123457' HOUR TO SECOND INTERVAL '1:02:03.123457' HOUR TO SECOND
> INTERVAL '-1:02' HOUR TO MINUTE INTERVAL '-1:02:03.123457' HOUR TO SECOND INTERVAL '-1:02:03.123457' HOUR TO SECOND
> rows (ordered): 2
SELECT J01, J02, J03, J04, J05, J06 FROM TEST ORDER BY ID;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论