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

Fix ValueInterval.compareTypeSafe()

上级 18f836ec
......@@ -225,11 +225,14 @@ public class ValueInterval extends Value {
@Override
public int compareTypeSafe(Value v, CompareMode mode) {
ValueInterval other = (ValueInterval) v;
if (negative != other.negative) {
return negative ? -1 : 1;
}
int cmp = Long.compare(leading, other.leading);
if (cmp == 0) {
cmp = Long.compare(remaining, other.remaining);
}
return cmp;
return negative ? -cmp : cmp;
}
@Override
......
......@@ -701,3 +701,24 @@ SELECT TIMESTAMP '2010-01-15 12:00:00.5+01' - TIMESTAMP WITH TIME ZONE '2010-01-
SELECT TIMESTAMP WITH TIME ZONE '2010-01-15 12:00:00.5+01' - TIMESTAMP '2010-01-13 01:30:00+02';
>> INTERVAL '2 11:30:00.5' DAY TO SECOND
CREATE TABLE TEST(I INTERVAL YEAR TO MONTH);
> ok
INSERT INTO TEST VALUES ('-0-0'), ('-0-1'), ('-1-1'), ('1-0'), ('0-1'), ('1-1'), ('-1-0');
> update count: 7
SELECT * FROM TEST ORDER BY I;
> I
> -----------------------------
> INTERVAL '-1-1' YEAR TO MONTH
> INTERVAL '-1-0' YEAR TO MONTH
> INTERVAL '-0-1' YEAR TO MONTH
> INTERVAL '0-0' YEAR TO MONTH
> INTERVAL '0-1' YEAR TO MONTH
> INTERVAL '1-0' YEAR TO MONTH
> INTERVAL '1-1' YEAR TO MONTH
> rows (ordered): 7
DROP TABLE TEST;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论