Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
935dd554
Unverified
提交
935dd554
authored
3月 23, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
3月 23, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1017 from katzyn/enum
Return name from ValueEnumBase.getObject()
上级
cc0f5b06
5bfbe4da
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
65 行增加
和
3 行删除
+65
-3
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
Value.java
h2/src/main/org/h2/value/Value.java
+10
-1
ValueEnumBase.java
h2/src/main/org/h2/value/ValueEnumBase.java
+1
-1
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+1
-1
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+51
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
935dd554
...
@@ -21,6 +21,8 @@ Change Log
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue #1016: ResultSet.getObject() should return enum value, not ordinal
</li>
<li>
Issue #1012: NPE when querying INFORMATION_SCHEMA.COLUMNS on a view that references an ENUM column
<li>
Issue #1012: NPE when querying INFORMATION_SCHEMA.COLUMNS on a view that references an ENUM column
</li>
</li>
<li>
Issue #1010: MERGE USING table not found with qualified table
<li>
Issue #1010: MERGE USING table not found with qualified table
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
935dd554
...
@@ -982,6 +982,15 @@ public abstract class Value {
...
@@ -982,6 +982,15 @@ public abstract class Value {
case
STRING_IGNORECASE:
case
STRING_IGNORECASE:
case
STRING_FIXED:
case
STRING_FIXED:
return
ValueEnum
.
get
(
enumerators
,
getString
());
return
ValueEnum
.
get
(
enumerators
,
getString
());
case
JAVA_OBJECT:
Object
object
=
JdbcUtils
.
deserialize
(
getBytesNoCopy
(),
getDataHandler
());
if
(
object
instanceof
String
)
{
return
ValueEnum
.
get
(
enumerators
,
(
String
)
object
);
}
else
if
(
object
instanceof
Integer
)
{
return
ValueEnum
.
get
(
enumerators
,
(
int
)
object
);
}
//$FALL-THROUGH$
default
:
default
:
throw
DbException
.
get
(
throw
DbException
.
get
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
getString
());
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
getString
());
...
...
h2/src/main/org/h2/value/ValueEnumBase.java
浏览文件 @
935dd554
...
@@ -77,7 +77,7 @@ public class ValueEnumBase extends Value {
...
@@ -77,7 +77,7 @@ public class ValueEnumBase extends Value {
@Override
@Override
public
Object
getObject
()
{
public
Object
getObject
()
{
return
ordina
l
;
return
labe
l
;
}
}
@Override
@Override
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
935dd554
...
@@ -476,7 +476,7 @@ public class TestPreparedStatement extends TestBase {
...
@@ -476,7 +476,7 @@ public class TestPreparedStatement extends TestBase {
assertEquals
(
goodSizes
[
i
],
rs
.
getString
(
1
));
assertEquals
(
goodSizes
[
i
],
rs
.
getString
(
1
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
Object
o
=
rs
.
getObject
(
1
);
Object
o
=
rs
.
getObject
(
1
);
assertEquals
(
Integer
.
class
,
o
.
getClass
());
assertEquals
(
String
.
class
,
o
.
getClass
());
}
}
for
(
int
i
=
0
;
i
<
goodSizes
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
goodSizes
.
length
;
i
++)
{
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
935dd554
...
@@ -87,6 +87,7 @@ public class TestResultSet extends TestBase {
...
@@ -87,6 +87,7 @@ public class TestResultSet extends TestBase {
testFindColumn
();
testFindColumn
();
testColumnLength
();
testColumnLength
();
testArray
();
testArray
();
testEnum
();
testLimitMaxRows
();
testLimitMaxRows
();
trace
(
"max rows="
+
stat
.
getMaxRows
());
trace
(
"max rows="
+
stat
.
getMaxRows
());
...
@@ -1798,6 +1799,56 @@ public class TestResultSet extends TestBase {
...
@@ -1798,6 +1799,56 @@ public class TestResultSet extends TestBase {
stat
.
execute
(
"DROP TABLE TEST"
);
stat
.
execute
(
"DROP TABLE TEST"
);
}
}
private
void
testEnum
()
throws
SQLException
{
trace
(
"Test ENUM"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, VALUE ENUM('A', 'B', 'C', 'D', 'E', 'F', 'G'))"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, ?)"
);
prep
.
setInt
(
1
,
1
);
prep
.
setString
(
2
,
"A"
);
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
2
);
prep
.
setObject
(
2
,
"B"
);
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
3
);
prep
.
setInt
(
2
,
2
);
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
4
);
prep
.
setObject
(
2
,
"D"
,
Types
.
VARCHAR
);
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
5
);
prep
.
setObject
(
2
,
"E"
,
Types
.
OTHER
);
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
6
);
prep
.
setObject
(
2
,
5
,
Types
.
OTHER
);
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
7
);
prep
.
setObject
(
2
,
6
,
Types
.
INTEGER
);
prep
.
executeUpdate
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
testEnumResult
(
rs
,
1
,
"A"
,
0
);
testEnumResult
(
rs
,
2
,
"B"
,
1
);
testEnumResult
(
rs
,
3
,
"C"
,
2
);
testEnumResult
(
rs
,
4
,
"D"
,
3
);
testEnumResult
(
rs
,
5
,
"E"
,
4
);
testEnumResult
(
rs
,
6
,
"F"
,
5
);
testEnumResult
(
rs
,
7
,
"G"
,
6
);
assertFalse
(
rs
.
next
());
stat
.
execute
(
"DROP TABLE TEST"
);
}
private
void
testEnumResult
(
ResultSet
rs
,
int
id
,
String
name
,
int
ordinal
)
throws
SQLException
{
assertTrue
(
rs
.
next
());
assertEquals
(
id
,
rs
.
getInt
(
1
));
assertEquals
(
name
,
rs
.
getString
(
2
));
assertEquals
(
name
,
rs
.
getObject
(
2
));
assertEquals
(
name
,
rs
.
getObject
(
2
,
String
.
class
));
assertEquals
(
ordinal
,
rs
.
getInt
(
2
));
assertEquals
((
Integer
)
ordinal
,
rs
.
getObject
(
2
,
Integer
.
class
));
}
private
byte
[]
readAllBytes
(
InputStream
in
)
{
private
byte
[]
readAllBytes
(
InputStream
in
)
{
if
(
in
==
null
)
{
if
(
in
==
null
)
{
return
null
;
return
null
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论