Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
245314a7
提交
245314a7
authored
13 年前
作者:
Sergi.Vladykin@gmail.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ClassCastException fixed for UUID primary keys
上级
06e97e0e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
32 行增加
和
0 行删除
+32
-0
FullText.java
h2/src/main/org/h2/fulltext/FullText.java
+4
-0
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+28
-0
没有找到文件。
h2/src/main/org/h2/fulltext/FullText.java
浏览文件 @
245314a7
...
@@ -23,6 +23,7 @@ import java.util.HashMap;
...
@@ -23,6 +23,7 @@ import java.util.HashMap;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.StringTokenizer
;
import
java.util.StringTokenizer
;
import
java.util.UUID
;
import
org.h2.api.Trigger
;
import
org.h2.api.Trigger
;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
...
@@ -490,6 +491,9 @@ public class FullText {
...
@@ -490,6 +491,9 @@ public class FullText {
case
Types
.
VARBINARY
:
case
Types
.
VARBINARY
:
case
Types
.
LONGVARBINARY
:
case
Types
.
LONGVARBINARY
:
case
Types
.
BINARY
:
case
Types
.
BINARY
:
if
(
data
instanceof
UUID
)
{
return
"'"
+
data
.
toString
()
+
"'"
;
}
return
"'"
+
StringUtils
.
convertBytesToHex
((
byte
[])
data
)
+
"'"
;
return
"'"
+
StringUtils
.
convertBytesToHex
((
byte
[])
data
)
+
"'"
;
case
Types
.
CLOB
:
case
Types
.
CLOB
:
case
Types
.
JAVA_OBJECT
:
case
Types
.
JAVA_OBJECT
:
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
245314a7
...
@@ -14,6 +14,7 @@ import java.sql.SQLException;
...
@@ -14,6 +14,7 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.StringTokenizer
;
import
java.util.StringTokenizer
;
import
java.util.UUID
;
import
org.h2.fulltext.FullText
;
import
org.h2.fulltext.FullText
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
...
@@ -39,6 +40,7 @@ public class TestFullText extends TestBase {
...
@@ -39,6 +40,7 @@ public class TestFullText extends TestBase {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
testUuidPrimaryKey
(
false
);
testAutoAnalyze
();
testAutoAnalyze
();
testNativeFeatures
();
testNativeFeatures
();
testTransaction
(
false
);
testTransaction
(
false
);
...
@@ -54,6 +56,7 @@ public class TestFullText extends TestBase {
...
@@ -54,6 +56,7 @@ public class TestFullText extends TestBase {
String
luceneFullTextClassName
=
"org.h2.fulltext.FullTextLucene"
;
String
luceneFullTextClassName
=
"org.h2.fulltext.FullTextLucene"
;
try
{
try
{
Class
.
forName
(
luceneFullTextClassName
);
Class
.
forName
(
luceneFullTextClassName
);
testUuidPrimaryKey
(
true
);
testMultiThreaded
(
true
);
testMultiThreaded
(
true
);
testMultiThreaded
(
false
);
testMultiThreaded
(
false
);
testTransaction
(
true
);
testTransaction
(
true
);
...
@@ -149,6 +152,31 @@ public class TestFullText extends TestBase {
...
@@ -149,6 +152,31 @@ public class TestFullText extends TestBase {
conn
.
close
();
conn
.
close
();
}
}
private
void
testUuidPrimaryKey
(
boolean
lucene
)
throws
SQLException
{
deleteDb
(
"fullText"
);
Connection
conn
=
getConnection
(
"fullText"
);
Statement
stat
=
conn
.
createStatement
();
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS "
+
prefix
+
"_INIT FOR \"org.h2.fulltext."
+
className
+
".init\""
);
stat
.
execute
(
"CALL "
+
prefix
+
"_INIT()"
);
stat
.
execute
(
"CREATE TABLE TEST(ID UUID PRIMARY KEY, NAME VARCHAR)"
);
String
id
=
UUID
.
randomUUID
().
toString
();
stat
.
execute
(
"INSERT INTO TEST VALUES('"
+
id
+
"', 'Hello World')"
);
stat
.
execute
(
"CALL "
+
prefix
+
"_CREATE_INDEX('PUBLIC', 'TEST', 'NAME')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('Hello', 0, 0)"
);
assertTrue
(
rs
.
next
());
stat
.
execute
(
"UPDATE TEST SET NAME=NULL WHERE ID='"
+
id
+
"'"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('Hello', 0, 0)"
);
assertFalse
(
rs
.
next
());
stat
.
execute
(
"UPDATE TEST SET NAME='Good Bye' WHERE ID='"
+
id
+
"'"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('bye', 0, 0)"
);
assertTrue
(
rs
.
next
());
FullText
.
dropAll
(
conn
);
conn
.
close
();
deleteDb
(
"fullText"
);
}
private
void
testTransaction
(
boolean
lucene
)
throws
SQLException
{
private
void
testTransaction
(
boolean
lucene
)
throws
SQLException
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论