Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6be41dec
Unverified
提交
6be41dec
authored
7月 19, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
7月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1311 from katzyn/misc
Fix minor issues with ResultSet.getObject(..., Class) and WITH TIES
上级
0494963b
edeb2c89
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
37 行增加
和
19 行删除
+37
-19
Query.java
h2/src/main/org/h2/command/dml/Query.java
+2
-1
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+2
-2
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+2
-15
TestSpatial.java
h2/src/test/org/h2/test/db/TestSpatial.java
+7
-0
select.sql
h2/src/test/org/h2/test/scripts/dml/select.sql
+17
-0
TestTimeStampWithTimeZone.java
h2/src/test/org/h2/test/unit/TestTimeStampWithTimeZone.java
+7
-1
没有找到文件。
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
6be41dec
...
@@ -703,7 +703,8 @@ public abstract class Query extends Prepared {
...
@@ -703,7 +703,8 @@ public abstract class Query extends Prepared {
if
(
offsetExpr
!=
null
)
{
if
(
offsetExpr
!=
null
)
{
buff
.
append
(
"\nOFFSET "
).
append
(
StringUtils
.
unEnclose
(
offsetExpr
.
getSQL
())).
append
(
" ROWS"
);
buff
.
append
(
"\nOFFSET "
).
append
(
StringUtils
.
unEnclose
(
offsetExpr
.
getSQL
())).
append
(
" ROWS"
);
}
}
buff
.
append
(
"\nFETCH NEXT "
).
append
(
StringUtils
.
unEnclose
(
limitExpr
.
getSQL
())).
append
(
" ROWS WITH TIES"
);
buff
.
append
(
"\nFETCH NEXT "
).
append
(
StringUtils
.
unEnclose
(
limitExpr
.
getSQL
()))
.
append
(
" ROWS WITH TIES"
);
}
else
{
}
else
{
buff
.
append
(
"\nLIMIT "
).
append
(
StringUtils
.
unEnclose
(
limitExpr
.
getSQL
()));
buff
.
append
(
"\nLIMIT "
).
append
(
StringUtils
.
unEnclose
(
limitExpr
.
getSQL
()));
if
(
offsetExpr
!=
null
)
{
if
(
offsetExpr
!=
null
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
6be41dec
...
@@ -3928,9 +3928,9 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
...
@@ -3928,9 +3928,9 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
return
type
.
cast
(
value
==
ValueNull
.
INSTANCE
return
type
.
cast
(
value
==
ValueNull
.
INSTANCE
?
null
:
new
JdbcSQLXML
(
conn
,
value
,
JdbcLob
.
State
.
WITH_VALUE
,
id
));
?
null
:
new
JdbcSQLXML
(
conn
,
value
,
JdbcLob
.
State
.
WITH_VALUE
,
id
));
}
else
if
(
type
==
TimestampWithTimeZone
.
class
)
{
}
else
if
(
type
==
TimestampWithTimeZone
.
class
)
{
return
type
.
cast
(
value
.
getObject
());
return
type
.
cast
(
value
.
convertTo
(
Value
.
TIMESTAMP_TZ
).
getObject
());
}
else
if
(
DataType
.
isGeometryClass
(
type
))
{
}
else
if
(
DataType
.
isGeometryClass
(
type
))
{
return
type
.
cast
(
value
.
getObject
());
return
type
.
cast
(
value
.
convertTo
(
Value
.
GEOMETRY
).
getObject
());
}
else
if
(
type
==
LocalDateTimeUtils
.
LOCAL_DATE
)
{
}
else
if
(
type
==
LocalDateTimeUtils
.
LOCAL_DATE
)
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalDate
(
value
));
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalDate
(
value
));
}
else
if
(
type
==
LocalDateTimeUtils
.
LOCAL_TIME
)
{
}
else
if
(
type
==
LocalDateTimeUtils
.
LOCAL_TIME
)
{
...
...
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
6be41dec
...
@@ -405,15 +405,8 @@ public class LocalResult implements ResultInterface, ResultTarget {
...
@@ -405,15 +405,8 @@ public class LocalResult implements ResultInterface, ResultTarget {
}
}
int
to
=
offset
+
limit
;
int
to
=
offset
+
limit
;
if
(
withTies
&&
sort
!=
null
)
{
if
(
withTies
&&
sort
!=
null
)
{
int
[]
indexes
=
sort
.
getQueryColumnIndexes
();
Value
[]
expected
=
rows
.
get
(
to
-
1
);
Value
[]
expected
=
rows
.
get
(
to
-
1
);
loop:
while
(
to
<
rows
.
size
())
{
while
(
to
<
rows
.
size
()
&&
sort
.
compare
(
expected
,
rows
.
get
(
to
))
==
0
)
{
Value
[]
current
=
rows
.
get
(
to
);
for
(
int
idx
:
indexes
)
{
if
(!
expected
[
idx
].
equals
(
current
[
idx
]))
{
break
loop
;
}
}
to
++;
to
++;
rowCount
++;
rowCount
++;
}
}
...
@@ -446,14 +439,8 @@ public class LocalResult implements ResultInterface, ResultTarget {
...
@@ -446,14 +439,8 @@ public class LocalResult implements ResultInterface, ResultTarget {
}
}
}
}
if
(
withTies
&&
sort
!=
null
&&
row
!=
null
)
{
if
(
withTies
&&
sort
!=
null
&&
row
!=
null
)
{
int
[]
indexes
=
sort
.
getQueryColumnIndexes
();
Value
[]
expected
=
row
;
Value
[]
expected
=
row
;
loop:
while
((
row
=
temp
.
next
())
!=
null
)
{
while
((
row
=
temp
.
next
())
!=
null
&&
sort
.
compare
(
expected
,
row
)
==
0
)
{
for
(
int
idx
:
indexes
)
{
if
(!
expected
[
idx
].
equals
(
row
[
idx
]))
{
break
loop
;
}
}
rows
.
add
(
row
);
rows
.
add
(
row
);
rowCount
++;
rowCount
++;
if
(
rows
.
size
()
>
maxMemoryRows
)
{
if
(
rows
.
size
()
>
maxMemoryRows
)
{
...
...
h2/src/test/org/h2/test/db/TestSpatial.java
浏览文件 @
6be41dec
...
@@ -149,6 +149,13 @@ public class TestSpatial extends TestDb {
...
@@ -149,6 +149,13 @@ public class TestSpatial extends TestDb {
new
Coordinate
(
2
,
2
),
new
Coordinate
(
2
,
2
),
new
Coordinate
(
1
,
1
)
});
new
Coordinate
(
1
,
1
)
});
assertTrue
(
polygon
.
equals
(
rs
.
getObject
(
2
)));
assertTrue
(
polygon
.
equals
(
rs
.
getObject
(
2
)));
rs
.
close
();
rs
=
stat
.
executeQuery
(
"select id, cast(polygon as varchar) from test"
);
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"POLYGON ((1 1, 1 2, 2 2, 1 1))"
,
rs
.
getObject
(
2
));
assertTrue
(
polygon
.
equals
(
rs
.
getObject
(
2
,
Geometry
.
class
)));
rs
.
close
();
rs
=
stat
.
executeQuery
(
"select * from test where polygon = "
+
rs
=
stat
.
executeQuery
(
"select * from test where polygon = "
+
"'POLYGON ((1 1, 1 2, 2 2, 1 1))'"
);
"'POLYGON ((1 1, 1 2, 2 2, 1 1))'"
);
...
...
h2/src/test/org/h2/test/scripts/dml/select.sql
浏览文件 @
6be41dec
...
@@ -131,3 +131,20 @@ EXPLAIN SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIE
...
@@ -131,3 +131,20 @@ EXPLAIN SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIE
DROP
TABLE
TEST
;
DROP
TABLE
TEST
;
>
ok
>
ok
CREATE
TABLE
TEST
(
A
NUMERIC
,
B
NUMERIC
);
>
ok
INSERT
INTO
TEST
VALUES
(
0
,
1
),
(
0
.
0
,
2
),
(
0
,
3
),
(
1
,
4
);
>
update
count
:
4
SELECT
A
,
B
FROM
TEST
ORDER
BY
A
FETCH
FIRST
1
ROW
WITH
TIES
;
>
A
B
>
--- -
>
0
1
>
0
3
>
0
.
0
2
>
rows
:
3
DROP
TABLE
TEST
;
>
ok
h2/src/test/org/h2/test/unit/TestTimeStampWithTimeZone.java
浏览文件 @
6be41dec
...
@@ -69,7 +69,8 @@ public class TestTimeStampWithTimeZone extends TestDb {
...
@@ -69,7 +69,8 @@ public class TestTimeStampWithTimeZone extends TestDb {
assertEquals
(
1
,
ts
.
getMonth
());
assertEquals
(
1
,
ts
.
getMonth
());
assertEquals
(
1
,
ts
.
getDay
());
assertEquals
(
1
,
ts
.
getDay
());
assertEquals
(
15
,
ts
.
getTimeZoneOffsetMins
());
assertEquals
(
15
,
ts
.
getTimeZoneOffsetMins
());
assertEquals
(
new
TimestampWithTimeZone
(
1008673L
,
43200000000000L
,
(
short
)
15
),
ts
);
TimestampWithTimeZone
firstExpected
=
new
TimestampWithTimeZone
(
1008673L
,
43200000000000L
,
(
short
)
15
);
assertEquals
(
firstExpected
,
ts
);
if
(
LocalDateTimeUtils
.
isJava8DateApiPresent
())
{
if
(
LocalDateTimeUtils
.
isJava8DateApiPresent
())
{
assertEquals
(
"1970-01-01T12:00+00:15"
,
rs
.
getObject
(
1
,
assertEquals
(
"1970-01-01T12:00+00:15"
,
rs
.
getObject
(
1
,
LocalDateTimeUtils
.
OFFSET_DATE_TIME
).
toString
());
LocalDateTimeUtils
.
OFFSET_DATE_TIME
).
toString
());
...
@@ -125,6 +126,11 @@ public class TestTimeStampWithTimeZone extends TestDb {
...
@@ -125,6 +126,11 @@ public class TestTimeStampWithTimeZone extends TestDb {
assertEquals
(
2014
,
columnType
);
assertEquals
(
2014
,
columnType
);
rs
.
close
();
rs
.
close
();
rs
=
stat
.
executeQuery
(
"select cast(t1 as varchar) from test"
);
assertTrue
(
rs
.
next
());
assertEquals
(
firstExpected
,
rs
.
getObject
(
1
,
TimestampWithTimeZone
.
class
));
stat
.
close
();
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论