Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c99ad8ad
提交
c99ad8ad
authored
7 年前
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup
上级
7ec1dbee
master
noel-pr1
version-1.4.198
version-1.4.197
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
22 行删除
+19
-22
ColumnNamer.java
h2/src/main/org/h2/util/ColumnNamer.java
+18
-19
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+1
-3
没有找到文件。
h2/src/main/org/h2/util/ColumnNamer.java
浏览文件 @
c99ad8ad
...
...
@@ -8,12 +8,12 @@ import org.h2.expression.Expression;
public
class
ColumnNamer
{
private
static
final
String
DEFAULT_COLUMN_NAME
=
"DEFAULT"
;
private
ColumnNamerConfiguration
configuration
;
private
Session
session
;
private
Set
<
String
>
existingColumnNames
=
new
HashSet
<
String
>();
private
final
Set
<
String
>
existingColumnNames
=
new
HashSet
<
>();
public
ColumnNamer
(
Session
session
)
{
this
.
session
=
session
;
...
...
@@ -31,9 +31,8 @@ public class ColumnNamer {
}
/**
* Create a standardized column name that isn't null and doesn't have a CR/LF in it.
* @param
columnExp
the column expression
* @param
expr
the column expression
* @param indexOfColumn index of column in below array
* @return
*/
public
String
getColumnName
(
Expression
expr
,
int
indexOfColumn
)
{
return
getColumnName
(
expr
,
indexOfColumn
,(
String
)
null
);
...
...
@@ -49,10 +48,10 @@ public class ColumnNamer {
String
columnNameOverride
=
null
;
if
(
columnNameOverides
!=
null
&&
columnNameOverides
.
length
>
indexOfColumn
){
columnNameOverride
=
columnNameOverides
[
indexOfColumn
];
}
}
return
getColumnName
(
columnExp
,
indexOfColumn
,
columnNameOverride
);
}
}
/**
* Create a standardized column name that isn't null and doesn't have a CR/LF in it.
* @param columnExp the column expression
...
...
@@ -67,11 +66,11 @@ public class ColumnNamer {
columnName
=
columnNameOverride
;
if
(!
isAllowableColumnName
(
columnName
)){
columnName
=
fixColumnName
(
columnName
);
}
}
if
(!
isAllowableColumnName
(
columnName
)){
columnName
=
null
;
}
}
}
// try a name from the column alias
if
(
columnName
==
null
&&
columnExp
.
getAlias
()!=
null
&&
!
DEFAULT_COLUMN_NAME
.
equals
(
columnExp
.
getAlias
())){
columnName
=
columnExp
.
getAlias
();
...
...
@@ -112,22 +111,22 @@ public class ColumnNamer {
existingColumnNames
.
add
(
columnName
);
return
columnName
;
}
private
String
generateUniqueName
(
String
columnName
)
{
String
newColumnName
=
columnName
;
int
loopCount
=
2
;
while
(
existingColumnNames
.
contains
(
newColumnName
)){
String
loopCountString
=
"_"
+
loopCount
;
newColumnName
=
columnName
.
substring
(
0
,
Math
.
min
(
columnName
.
length
(),
configuration
.
getMaxIdentiferLength
()-
loopCountString
.
length
()))+
loopCountString
;
loopCount
++;
}
return
newColumnName
;
}
public
boolean
isAllowableColumnName
(
String
proposedName
){
// check null
if
(
proposedName
==
null
){
return
false
;
...
...
@@ -142,21 +141,21 @@ public class ColumnNamer {
}
return
true
;
}
private
String
fixColumnName
(
String
proposedName
)
{
Matcher
match
=
configuration
.
getCompiledRegularExpressionMatchDisallowed
().
matcher
(
proposedName
);
proposedName
=
match
.
replaceAll
(
""
);
// check size limits - then truncate
if
(
proposedName
.
length
()
>
configuration
.
getMaxIdentiferLength
()){
proposedName
=
proposedName
.
substring
(
0
,
configuration
.
getMaxIdentiferLength
());
}
return
proposedName
;
}
public
ColumnNamerConfiguration
getConfiguration
()
{
return
configuration
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
c99ad8ad
...
...
@@ -11,8 +11,6 @@ import java.io.InputStream;
import
java.io.InputStreamReader
;
import
java.io.LineNumberReader
;
import
java.io.PrintStream
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
...
...
@@ -74,7 +72,7 @@ public class TestScript extends TestBase {
}
@Override
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
if
(
config
.
networked
&&
config
.
big
)
{
return
;
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论