Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b1359724
提交
b1359724
authored
10月 28, 2017
作者:
Owner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Another good test case (persistence between connections) fails the current implementation. Sigh.
上级
0c6d0c44
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
6 行删除
+17
-6
TestGeneralCommonTableQueries.java
...rc/test/org/h2/test/db/TestGeneralCommonTableQueries.java
+17
-6
没有找到文件。
h2/src/test/org/h2/test/db/TestGeneralCommonTableQueries.java
浏览文件 @
b1359724
...
@@ -517,11 +517,11 @@ public class TestGeneralCommonTableQueries extends TestBase {
...
@@ -517,11 +517,11 @@ public class TestGeneralCommonTableQueries extends TestBase {
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumbeOfRows
,
SETUP_SQL
,
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumbeOfRows
,
SETUP_SQL
,
WITH_QUERY
);
WITH_QUERY
,
maxRetries
-
1
);
}
}
private
void
testRepeatedQueryWithSetup
(
int
maxRetries
,
String
[]
expectedRowData
,
String
[]
expectedColumnNames
,
private
void
testRepeatedQueryWithSetup
(
int
maxRetries
,
String
[]
expectedRowData
,
String
[]
expectedColumnNames
,
int
expectedNumbeOfRows
,
String
SETUP_SQL
,
String
WITH_QUERY
)
throws
SQLException
{
int
expectedNumbeOfRows
,
String
SETUP_SQL
,
String
WITH_QUERY
,
int
closeAndReopenDatabaseConnectionOnIteration
)
throws
SQLException
{
deleteDb
(
"commonTableExpressionQueries"
);
deleteDb
(
"commonTableExpressionQueries"
);
Connection
conn
=
getConnection
(
"commonTableExpressionQueries"
);
Connection
conn
=
getConnection
(
"commonTableExpressionQueries"
);
...
@@ -529,11 +529,20 @@ public class TestGeneralCommonTableQueries extends TestBase {
...
@@ -529,11 +529,20 @@ public class TestGeneralCommonTableQueries extends TestBase {
ResultSet
rs
;
ResultSet
rs
;
for
(
int
queryRunTries
=
1
;
queryRunTries
<=
maxRetries
;
queryRunTries
++){
for
(
int
queryRunTries
=
1
;
queryRunTries
<=
maxRetries
;
queryRunTries
++){
System
.
out
.
println
(
"Iteration #"
+
queryRunTries
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
SETUP_SQL
);
stat
.
execute
(
SETUP_SQL
);
stat
.
close
();
stat
.
close
();
// close and re-open connection for one iteration to make sure the query work between connections
if
(
queryRunTries
==
closeAndReopenDatabaseConnectionOnIteration
){
System
.
out
.
println
(
"Reconnecting to database on iteration#"
+
queryRunTries
+
" of "
+
maxRetries
);
conn
.
close
();
conn
=
getConnection
(
"commonTableExpressionQueries"
);
}
prep
=
conn
.
prepareStatement
(
WITH_QUERY
);
prep
=
conn
.
prepareStatement
(
WITH_QUERY
);
rs
=
prep
.
executeQuery
();
rs
=
prep
.
executeQuery
();
...
@@ -586,7 +595,8 @@ public class TestGeneralCommonTableQueries extends TestBase {
...
@@ -586,7 +595,8 @@ public class TestGeneralCommonTableQueries extends TestBase {
+
" SELECT sub_tree_root_id, mtc.tree_level + 1 AS tree_level, mtc.parent_fk, mt.id \n"
+
" SELECT sub_tree_root_id, mtc.tree_level + 1 AS tree_level, mtc.parent_fk, mt.id \n"
+
" FROM my_tree mt \n"
+
" FROM my_tree mt \n"
+
"INNER JOIN tree_cte mtc ON mtc.child_fk = mt.parent_fk \n"
+
"INNER JOIN tree_cte mtc ON mtc.child_fk = mt.parent_fk \n"
+
") \n"
+
"), \n"
+
"unused_cte AS ( SELECT 1 AS unUsedColumn ) \n"
+
"SELECT sub_tree_root_id, tree_level, parent_fk, child_fk FROM tree_cte; \n"
+
"SELECT sub_tree_root_id, tree_level, parent_fk, child_fk FROM tree_cte; \n"
;
;
...
@@ -607,7 +617,7 @@ public class TestGeneralCommonTableQueries extends TestBase {
...
@@ -607,7 +617,7 @@ public class TestGeneralCommonTableQueries extends TestBase {
String
[]
expectedColumnNames
=
new
String
[]{
"SUB_TREE_ROOT_ID"
,
"TREE_LEVEL"
,
"PARENT_FK"
,
"CHILD_FK"
};
String
[]
expectedColumnNames
=
new
String
[]{
"SUB_TREE_ROOT_ID"
,
"TREE_LEVEL"
,
"PARENT_FK"
,
"CHILD_FK"
};
int
expectedNumbeOfRows
=
11
;
int
expectedNumbeOfRows
=
11
;
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumbeOfRows
,
SETUP_SQL
,
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumbeOfRows
,
SETUP_SQL
,
WITH_QUERY
);
WITH_QUERY
,
maxRetries
-
1
);
}
}
private
void
testNonRecursiveTableInCreateView
()
throws
Exception
{
private
void
testNonRecursiveTableInCreateView
()
throws
Exception
{
String
SETUP_SQL
=
""
String
SETUP_SQL
=
""
...
@@ -628,7 +638,8 @@ public class TestGeneralCommonTableQueries extends TestBase {
...
@@ -628,7 +638,8 @@ public class TestGeneralCommonTableQueries extends TestBase {
+
"WITH tree_cte_nr (sub_tree_root_id, tree_level, parent_fk, child_fk) AS ( \n"
+
"WITH tree_cte_nr (sub_tree_root_id, tree_level, parent_fk, child_fk) AS ( \n"
+
" SELECT mt.ID AS sub_tree_root_id, CAST(0 AS INT) AS tree_level, mt.parent_fk, mt.id \n"
+
" SELECT mt.ID AS sub_tree_root_id, CAST(0 AS INT) AS tree_level, mt.parent_fk, mt.id \n"
+
" FROM my_table mt \n"
+
" FROM my_table mt \n"
+
") \n"
+
"), \n"
+
"unused_cte AS ( SELECT 1 AS unUsedColumn ) \n"
+
"SELECT sub_tree_root_id, tree_level, parent_fk, child_fk FROM tree_cte_nr; \n"
+
"SELECT sub_tree_root_id, tree_level, parent_fk, child_fk FROM tree_cte_nr; \n"
;
;
...
@@ -644,6 +655,6 @@ public class TestGeneralCommonTableQueries extends TestBase {
...
@@ -644,6 +655,6 @@ public class TestGeneralCommonTableQueries extends TestBase {
String
[]
expectedColumnNames
=
new
String
[]{
"SUB_TREE_ROOT_ID"
,
"TREE_LEVEL"
,
"PARENT_FK"
,
"CHILD_FK"
};
String
[]
expectedColumnNames
=
new
String
[]{
"SUB_TREE_ROOT_ID"
,
"TREE_LEVEL"
,
"PARENT_FK"
,
"CHILD_FK"
};
int
expectedNumbeOfRows
=
5
;
int
expectedNumbeOfRows
=
5
;
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumbeOfRows
,
SETUP_SQL
,
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumbeOfRows
,
SETUP_SQL
,
WITH_QUERY
);
WITH_QUERY
,
maxRetries
-
1
);
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论