Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
cfb2cc37
提交
cfb2cc37
authored
5月 06, 2015
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
There was a bug in DataType.convertToValue when reading a ResultSet from a ResultSet.
上级
7c1c0f36
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
63 行增加
和
10 行删除
+63
-10
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
DataType.java
h2/src/main/org/h2/value/DataType.java
+10
-9
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+51
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
cfb2cc37
...
...
@@ -20,7 +20,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Pull request #116: Improved concurrency in the trace system.
<ul><li>
There was a bug in DataType.convertToValue when reading a ResultSet from a ResultSet.
</li><li>
Pull request #116: Improved concurrency in the trace system.
</li><li>
Issue 609: the spatial index did not support NULL.
</li><li>
Granting a schema is now supported.
</li><li>
Linked tables did not work when a function-based index is present (Oracle).
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
cfb2cc37
...
...
@@ -595,8 +595,9 @@ public class DataType {
}
case
Value
.
CLOB
:
{
if
(
session
==
null
)
{
v
=
ValueLobDb
.
createSmallLob
(
Value
.
CLOB
,
rs
.
getString
(
columnIndex
).
getBytes
(
Constants
.
UTF8
));
String
s
=
rs
.
getString
(
columnIndex
);
v
=
s
==
null
?
ValueNull
.
INSTANCE
:
ValueLobDb
.
createSmallLob
(
Value
.
CLOB
,
s
.
getBytes
(
Constants
.
UTF8
));
}
else
{
Reader
in
=
rs
.
getCharacterStream
(
columnIndex
);
if
(
in
==
null
)
{
...
...
@@ -610,13 +611,13 @@ public class DataType {
}
case
Value
.
BLOB
:
{
if
(
session
==
null
)
{
v
=
ValueLobDb
.
createSmallLob
(
Value
.
BLOB
,
rs
.
getBytes
(
columnIndex
));
}
else
{
byte
[]
buff
=
rs
.
getBytes
(
columnIndex
);
return
buff
==
null
?
ValueNull
.
INSTANCE
:
ValueLobDb
.
createSmallLob
(
Value
.
BLOB
,
buff
);
}
InputStream
in
=
rs
.
getBinaryStream
(
columnIndex
);
v
=
(
in
==
null
)
?
(
Value
)
ValueNull
.
INSTANCE
:
session
.
getDataHandler
().
getLobStorage
().
createBlob
(
in
,
-
1
);
}
break
;
}
case
Value
.
JAVA_OBJECT
:
{
...
...
@@ -653,7 +654,7 @@ public class DataType {
if
(
x
==
null
)
{
return
ValueNull
.
INSTANCE
;
}
return
ValueResultSet
.
get
(
rs
);
return
ValueResultSet
.
get
(
x
);
}
case
Value
.
GEOMETRY
:
{
Object
x
=
rs
.
getObject
(
columnIndex
);
...
...
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
cfb2cc37
...
...
@@ -27,6 +27,7 @@ import org.h2.value.ValueDecimal;
import
org.h2.value.ValueDouble
;
import
org.h2.value.ValueFloat
;
import
org.h2.value.ValueLobDb
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueResultSet
;
import
org.h2.value.ValueString
;
import
org.h2.value.ValueUuid
;
...
...
@@ -47,6 +48,7 @@ public class TestValue extends TestBase {
@Override
public
void
test
()
throws
SQLException
{
testResultSetOperations
();
testCastTrim
();
testValueResultSet
();
testDataType
();
...
...
@@ -58,6 +60,55 @@ public class TestValue extends TestBase {
testModulusOperator
();
}
private
void
testResultSetOperations
()
throws
SQLException
{
SimpleResultSet
rs
=
new
SimpleResultSet
();
rs
.
setAutoClose
(
false
);
rs
.
addColumn
(
"X"
,
Types
.
INTEGER
,
10
,
0
);
rs
.
addRow
(
new
Object
[]{
null
});
rs
.
next
();
for
(
int
type
=
Value
.
NULL
;
type
<
Value
.
TYPE_COUNT
;
type
++)
{
Value
v
=
DataType
.
readValue
(
null
,
rs
,
1
,
type
);
assertTrue
(
v
==
ValueNull
.
INSTANCE
);
}
testResultSetOperation
(
new
byte
[
0
]);
testResultSetOperation
(
1
);
testResultSetOperation
(
Boolean
.
TRUE
);
testResultSetOperation
((
byte
)
1
);
testResultSetOperation
((
short
)
2
);
testResultSetOperation
((
long
)
3
);
testResultSetOperation
(
4.0f
);
testResultSetOperation
(
5.0d
);
testResultSetOperation
(
new
Date
(
6
));
testResultSetOperation
(
new
Time
(
7
));
testResultSetOperation
(
new
Timestamp
(
8
));
testResultSetOperation
(
new
BigDecimal
(
"9"
));
SimpleResultSet
rs2
=
new
SimpleResultSet
();
rs2
.
setAutoClose
(
false
);
rs2
.
addColumn
(
"X"
,
Types
.
INTEGER
,
10
,
0
);
rs2
.
addRow
(
new
Object
[]{
1
});
rs2
.
next
();
testResultSetOperation
(
rs2
);
}
private
void
testResultSetOperation
(
Object
obj
)
throws
SQLException
{
SimpleResultSet
rs
=
new
SimpleResultSet
();
rs
.
setAutoClose
(
false
);
int
valueType
=
DataType
.
getTypeFromClass
(
obj
.
getClass
());
int
sqlType
=
DataType
.
convertTypeToSQLType
(
valueType
);
rs
.
addColumn
(
"X"
,
sqlType
,
10
,
0
);
rs
.
addRow
(
new
Object
[]{
obj
});
rs
.
next
();
Value
v
=
DataType
.
readValue
(
null
,
rs
,
1
,
valueType
);
Value
v2
=
DataType
.
convertToValue
(
null
,
obj
,
valueType
);
if
(
v
.
getType
()
==
Value
.
RESULT_SET
)
{
assertEquals
(
v
.
toString
(),
v2
.
toString
());
}
else
{
assertTrue
(
v
.
equals
(
v2
));
}
}
private
void
testCastTrim
()
{
Value
v
;
String
spaces
=
new
String
(
new
char
[
100
]).
replace
((
char
)
0
,
' '
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论