Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0a6aa17d
提交
0a6aa17d
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add StringUtils.join()
上级
edba4fd8
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
28 行增加
和
21 行删除
+28
-21
Parser.java
h2/src/main/org/h2/command/Parser.java
+1
-7
DropTable.java
h2/src/main/org/h2/command/ddl/DropTable.java
+8
-8
WebApp.java
h2/src/main/org/h2/server/web/WebApp.java
+1
-6
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+18
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
0a6aa17d
...
...
@@ -218,7 +218,6 @@ import org.h2.table.TableFilter.TableFilterVisitor;
import
org.h2.table.TableView
;
import
org.h2.util.IntervalUtils
;
import
org.h2.util.ParserUtil
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
import
org.h2.util.geometry.EWKTUtils
;
...
...
@@ -981,13 +980,8 @@ public class Parser {
if
(
expectedList
==
null
||
expectedList
.
isEmpty
())
{
return
DbException
.
getSyntaxError
(
sqlCommand
,
parseIndex
);
}
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
String
e
:
expectedList
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
e
);
}
return
DbException
.
getSyntaxError
(
sqlCommand
,
parseIndex
,
buff
.
toString
());
StringUtils
.
join
(
new
StringBuilder
(),
expectedList
,
", "
)
.
toString
());
}
private
Prepared
parseBackup
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/DropTable.java
浏览文件 @
0a6aa17d
...
...
@@ -5,6 +5,7 @@
*/
package
org
.
h2
.
command
.
ddl
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
org.h2.api.ErrorCode
;
...
...
@@ -18,7 +19,7 @@ import org.h2.message.DbException;
import
org.h2.schema.Schema
;
import
org.h2.table.Table
;
import
org.h2.table.TableView
;
import
org.h2.util.St
atementBuilder
;
import
org.h2.util.St
ringUtils
;
/**
* This class represents the statement
...
...
@@ -75,12 +76,11 @@ public class DropTable extends SchemaCommand {
throw
DbException
.
get
(
ErrorCode
.
CANNOT_DROP_TABLE_1
,
tableName
);
}
if
(
dropAction
==
ConstraintActionType
.
RESTRICT
)
{
StatementBuilder
buff
=
new
StatementBuilder
();
ArrayList
<
String
>
dependencies
=
new
ArrayList
<>
();
CopyOnWriteArrayList
<
TableView
>
dependentViews
=
table
.
getDependentViews
();
if
(
dependentViews
!=
null
&&
!
dependentViews
.
isEmpty
())
{
for
(
TableView
v
:
dependentViews
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
v
.
getName
());
dependencies
.
add
(
v
.
getName
());
}
}
if
(
session
.
getDatabase
()
...
...
@@ -89,14 +89,14 @@ public class DropTable extends SchemaCommand {
if
(
constraints
!=
null
&&
!
constraints
.
isEmpty
())
{
for
(
Constraint
c
:
constraints
)
{
if
(
c
.
getTable
()
!=
table
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getName
());
dependencies
.
add
(
c
.
getName
());
}
}
}
}
if
(
buff
.
length
()
>
0
)
{
throw
DbException
.
get
(
ErrorCode
.
CANNOT_DROP_2
,
tableName
,
buff
.
toString
());
if
(!
dependencies
.
isEmpty
())
{
throw
DbException
.
get
(
ErrorCode
.
CANNOT_DROP_2
,
tableName
,
StringUtils
.
join
(
new
StringBuilder
(),
dependencies
,
", "
).
toString
());
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
0a6aa17d
...
...
@@ -372,12 +372,7 @@ public class WebApp {
if
(
query
.
endsWith
(
"\n"
)
||
tQuery
.
endsWith
(
";"
))
{
list
.
add
(
0
,
"1#(Newline)#\n"
);
}
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
String
s
:
list
)
{
buff
.
appendExceptFirst
(
"|"
);
buff
.
append
(
s
);
}
result
=
buff
.
toString
();
result
=
StringUtils
.
join
(
new
StringBuilder
(),
list
,
"|"
).
toString
();
}
session
.
put
(
"autoCompleteList"
,
result
);
}
catch
(
Throwable
e
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
0a6aa17d
...
...
@@ -522,6 +522,24 @@ public class StringUtils {
return
builder
.
toString
();
}
/**
* Join specified strings and add them to the specified string builder.
*
* @param builder string builder
* @param strings strings to join
* @param separator separator
* @return the specified string builder
*/
public
static
StringBuilder
join
(
StringBuilder
builder
,
ArrayList
<
String
>
strings
,
String
separator
)
{
for
(
int
i
=
0
,
l
=
strings
.
size
();
i
<
l
;
i
++)
{
if
(
i
>
0
)
{
builder
.
append
(
separator
);
}
builder
.
append
(
strings
.
get
(
i
));
}
return
builder
;
}
/**
* Creates an XML attribute of the form name="value".
* A single space is prepended to the name,
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论