Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b056815f
提交
b056815f
authored
2月 12, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Column.writeColumns()
上级
4656131a
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
76 行增加
和
78 行删除
+76
-78
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+14
-17
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+15
-22
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+12
-15
Column.java
h2/src/main/org/h2/table/Column.java
+19
-0
TableView.java
h2/src/main/org/h2/table/TableView.java
+16
-24
没有找到文件。
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
b056815f
...
...
@@ -269,37 +269,34 @@ public class Insert extends CommandWithValues implements ResultTarget {
@Override
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"INSERT INTO "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
")\n"
);
StringBuilder
builder
=
new
StringBuilder
(
"INSERT INTO "
);
table
.
getSQL
(
builder
).
append
(
'('
);
Column
.
writeColumns
(
builder
,
columns
);
builder
.
append
(
")\n"
);
if
(
insertFromSelect
)
{
bu
ff
.
append
(
"DIRECT "
);
bu
ilder
.
append
(
"DIRECT "
);
}
if
(
sortedInsertMode
)
{
bu
ff
.
append
(
"SORTED "
);
bu
ilder
.
append
(
"SORTED "
);
}
if
(!
valuesExpressionList
.
isEmpty
())
{
bu
ff
.
append
(
"VALUES "
);
bu
ilder
.
append
(
"VALUES "
);
int
row
=
0
;
if
(
valuesExpressionList
.
size
()
>
1
)
{
bu
ff
.
append
(
'\n'
);
bu
ilder
.
append
(
'\n'
);
}
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
if
(
row
++
>
0
)
{
bu
ff
.
append
(
",\n"
);
bu
ilder
.
append
(
",\n"
);
}
bu
ff
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ff
.
builder
()
,
expr
);
bu
ff
.
append
(
')'
);
bu
ilder
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ilder
,
expr
);
bu
ilder
.
append
(
')'
);
}
}
else
{
bu
ff
.
append
(
query
.
getPlanSQL
());
bu
ilder
.
append
(
query
.
getPlanSQL
());
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
@Override
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
b056815f
...
...
@@ -206,38 +206,31 @@ public class Merge extends CommandWithValues {
@Override
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"MERGE INTO "
);
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
')'
);
StringBuilder
builder
=
new
StringBuilder
(
"MERGE INTO "
);
targetTable
.
getSQL
(
builder
).
append
(
'('
);
Column
.
writeColumns
(
builder
,
columns
);
builder
.
append
(
')'
);
if
(
keys
!=
null
)
{
buff
.
append
(
" KEY("
);
buff
.
resetCount
();
for
(
Column
c
:
keys
)
{
buff
.
appendExceptFirst
(
", "
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
')'
);
builder
.
append
(
" KEY("
);
Column
.
writeColumns
(
builder
,
keys
);
builder
.
append
(
')'
);
}
bu
ff
.
append
(
'\n'
);
bu
ilder
.
append
(
'\n'
);
if
(!
valuesExpressionList
.
isEmpty
())
{
bu
ff
.
append
(
"VALUES "
);
bu
ilder
.
append
(
"VALUES "
);
int
row
=
0
;
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
if
(
row
++
>
0
)
{
bu
ff
.
append
(
", "
);
bu
ilder
.
append
(
", "
);
}
bu
ff
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ff
.
builder
()
,
expr
);
bu
ff
.
append
(
')'
);
bu
ilder
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ilder
,
expr
);
bu
ilder
.
append
(
')'
);
}
}
else
{
bu
ff
.
append
(
query
.
getPlanSQL
());
bu
ilder
.
append
(
query
.
getPlanSQL
());
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
@Override
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
b056815f
...
...
@@ -195,29 +195,26 @@ public class Replace extends CommandWithValues {
@Override
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"REPLACE INTO "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
'('
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
')'
);
buff
.
append
(
'\n'
);
StringBuilder
builder
=
new
StringBuilder
(
"REPLACE INTO "
);
table
.
getSQL
(
builder
).
append
(
'('
);
Column
.
writeColumns
(
builder
,
columns
);
builder
.
append
(
')'
);
builder
.
append
(
'\n'
);
if
(!
valuesExpressionList
.
isEmpty
())
{
bu
ff
.
append
(
"VALUES "
);
bu
ilder
.
append
(
"VALUES "
);
int
row
=
0
;
for
(
Expression
[]
expr
:
valuesExpressionList
)
{
if
(
row
++
>
0
)
{
bu
ff
.
append
(
", "
);
bu
ilder
.
append
(
", "
);
}
bu
ff
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ff
.
builder
()
,
expr
);
bu
ff
.
append
(
')'
);
bu
ilder
.
append
(
'('
);
Expression
.
writeExpressions
(
bu
ilder
,
expr
);
bu
ilder
.
append
(
')'
);
}
}
else
{
bu
ff
.
append
(
query
.
getPlanSQL
());
bu
ilder
.
append
(
query
.
getPlanSQL
());
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
@Override
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
b056815f
...
...
@@ -86,6 +86,25 @@ public class Column {
private
boolean
visible
=
true
;
private
Domain
domain
;
/**
* Appends the specified columns to the specified builder.
*
* @param builder
* string builder
* @param columns
* columns
* @return the specified string builder
*/
public
static
StringBuilder
writeColumns
(
StringBuilder
builder
,
Column
[]
columns
)
{
for
(
int
i
=
0
,
l
=
columns
.
length
;
i
<
l
;
i
++)
{
if
(
i
>
0
)
{
builder
.
append
(
", "
);
}
columns
[
i
].
getSQL
(
builder
);
}
return
builder
;
}
public
Column
(
String
name
,
int
valueType
)
{
this
(
name
,
TypeInfo
.
getTypeInfo
(
valueType
));
}
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
b056815f
...
...
@@ -35,7 +35,6 @@ import org.h2.result.Row;
import
org.h2.result.SortOrder
;
import
org.h2.schema.Schema
;
import
org.h2.util.ColumnNamer
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
import
org.h2.value.TypeInfo
;
...
...
@@ -323,40 +322,33 @@ public class TableView extends Table {
return
getCreateSQL
(
orReplace
,
force
,
getSQL
());
}
private
String
getCreateSQL
(
boolean
orReplace
,
boolean
force
,
String
quotedName
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
"CREATE "
);
private
String
getCreateSQL
(
boolean
orReplace
,
boolean
force
,
String
quotedName
)
{
StringBuilder
builder
=
new
StringBuilder
(
"CREATE "
);
if
(
orReplace
)
{
bu
ff
.
append
(
"OR REPLACE "
);
bu
ilder
.
append
(
"OR REPLACE "
);
}
if
(
force
)
{
bu
ff
.
append
(
"FORCE "
);
bu
ilder
.
append
(
"FORCE "
);
}
bu
ff
.
append
(
"VIEW "
);
bu
ilder
.
append
(
"VIEW "
);
if
(
isTableExpression
)
{
bu
ff
.
append
(
"TABLE_EXPRESSION "
);
bu
ilder
.
append
(
"TABLE_EXPRESSION "
);
}
bu
ff
.
append
(
quotedName
);
bu
ilder
.
append
(
quotedName
);
if
(
comment
!=
null
)
{
bu
ff
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
bu
ff
.
builder
()
,
comment
);
bu
ilder
.
append
(
" COMMENT "
);
StringUtils
.
quoteStringSQL
(
bu
ilder
,
comment
);
}
if
(
columns
!=
null
&&
columns
.
length
>
0
)
{
buff
.
append
(
'('
);
for
(
Column
c
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
c
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
')'
);
builder
.
append
(
'('
);
Column
.
writeColumns
(
builder
,
columns
);
builder
.
append
(
')'
);
}
else
if
(
columnTemplates
!=
null
)
{
buff
.
append
(
'('
);
for
(
Column
c
:
columnTemplates
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
.
getName
());
}
buff
.
append
(
')'
);
builder
.
append
(
'('
);
Column
.
writeColumns
(
builder
,
columnTemplates
);
builder
.
append
(
')'
);
}
return
bu
ff
.
append
(
" AS\n"
).
append
(
querySQL
).
toString
();
return
bu
ilder
.
append
(
" AS\n"
).
append
(
querySQL
).
toString
();
}
@Override
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论