Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
15609e26
提交
15609e26
authored
2月 12, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Column.writeColumns(StringBuilder, Column[], String, String)
上级
950f82d5
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
35 行增加
和
36 行删除
+35
-36
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+5
-15
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+5
-15
Select.java
h2/src/main/org/h2/command/dml/Select.java
+1
-6
Column.java
h2/src/main/org/h2/table/Column.java
+24
-0
没有找到文件。
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
15609e26
...
@@ -26,7 +26,6 @@ import org.h2.result.Row;
...
@@ -26,7 +26,6 @@ import org.h2.result.Row;
import
org.h2.table.Column
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StatementBuilder
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
/**
/**
...
@@ -268,20 +267,11 @@ public class Merge extends CommandWithValues {
...
@@ -268,20 +267,11 @@ public class Merge extends CommandWithValues {
}
}
keys
=
idx
.
getColumns
();
keys
=
idx
.
getColumns
();
}
}
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
StringBuilder
builder
=
new
StringBuilder
(
"UPDATE "
);
targetTable
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
targetTable
.
getSQL
(
builder
).
append
(
" SET "
);
for
(
Column
c
:
columns
)
{
Column
.
writeColumns
(
builder
,
columns
,
", "
,
"=?"
).
append
(
" WHERE "
);
buff
.
appendExceptFirst
(
", "
);
Column
.
writeColumns
(
builder
,
keys
,
" AND "
,
"=?"
);
c
.
getSQL
(
buff
.
builder
()).
append
(
"=?"
);
update
=
session
.
prepare
(
builder
.
toString
());
}
buff
.
append
(
" WHERE "
);
buff
.
resetCount
();
for
(
Column
c
:
keys
)
{
buff
.
appendExceptFirst
(
" AND "
);
c
.
getSQL
(
buff
.
builder
()).
append
(
"=?"
);
}
String
sql
=
buff
.
toString
();
update
=
session
.
prepare
(
sql
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
15609e26
...
@@ -24,7 +24,6 @@ import org.h2.result.ResultInterface;
...
@@ -24,7 +24,6 @@ import org.h2.result.ResultInterface;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.table.Column
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.table.Table
;
import
org.h2.util.StatementBuilder
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
/**
/**
...
@@ -266,20 +265,11 @@ public class Replace extends CommandWithValues {
...
@@ -266,20 +265,11 @@ public class Replace extends CommandWithValues {
return
;
return
;
}
}
}
}
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
StringBuilder
builder
=
new
StringBuilder
(
"UPDATE "
);
table
.
getSQL
(
buff
.
builder
()).
append
(
" SET "
);
table
.
getSQL
(
builder
).
append
(
" SET "
);
for
(
Column
c
:
columns
)
{
Column
.
writeColumns
(
builder
,
columns
,
", "
,
"=?"
).
append
(
" WHERE "
);
buff
.
appendExceptFirst
(
", "
);
Column
.
writeColumns
(
builder
,
keys
,
" AND "
,
"=?"
);
c
.
getSQL
(
buff
.
builder
()).
append
(
"=?"
);
update
=
session
.
prepare
(
builder
.
toString
());
}
buff
.
append
(
" WHERE "
);
buff
.
resetCount
();
for
(
Column
c
:
keys
)
{
buff
.
appendExceptFirst
(
" AND "
);
c
.
getSQL
(
buff
.
builder
()).
append
(
"=?"
);
}
String
sql
=
buff
.
toString
();
update
=
session
.
prepare
(
sql
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
15609e26
...
@@ -1484,18 +1484,13 @@ public class Select extends Query {
...
@@ -1484,18 +1484,13 @@ public class Select extends Query {
}
}
}
}
}
}
buff
.
resetCount
();
buff
.
append
(
"SELECT"
);
buff
.
append
(
"SELECT"
);
if
(
isAnyDistinct
())
{
if
(
isAnyDistinct
())
{
buff
.
append
(
" DISTINCT"
);
buff
.
append
(
" DISTINCT"
);
if
(
distinctExpressions
!=
null
)
{
if
(
distinctExpressions
!=
null
)
{
buff
.
append
(
" ON("
);
buff
.
append
(
" ON("
);
for
(
Expression
distinctExpression:
distinctExpressions
)
{
Expression
.
writeExpressions
(
buff
.
builder
(),
distinctExpressions
);
buff
.
appendExceptFirst
(
", "
);
distinctExpression
.
getSQL
(
buff
.
builder
());
}
buff
.
append
(
')'
);
buff
.
append
(
')'
);
buff
.
resetCount
();
}
}
}
}
for
(
int
i
=
0
;
i
<
visibleColumnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
visibleColumnCount
;
i
++)
{
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
15609e26
...
@@ -105,6 +105,30 @@ public class Column {
...
@@ -105,6 +105,30 @@ public class Column {
return
builder
;
return
builder
;
}
}
/**
* Appends the specified columns to the specified builder.
*
* @param builder
* string builder
* @param columns
* columns
* @param separator
* separator
* @param suffix
* additional SQL to append after each column
* @return the specified string builder
*/
public
static
StringBuilder
writeColumns
(
StringBuilder
builder
,
Column
[]
columns
,
String
separator
,
String
suffix
)
{
for
(
int
i
=
0
,
l
=
columns
.
length
;
i
<
l
;
i
++)
{
if
(
i
>
0
)
{
builder
.
append
(
separator
);
}
columns
[
i
].
getSQL
(
builder
).
append
(
suffix
);
}
return
builder
;
}
public
Column
(
String
name
,
int
valueType
)
{
public
Column
(
String
name
,
int
valueType
)
{
this
(
name
,
TypeInfo
.
getTypeInfo
(
valueType
));
this
(
name
,
TypeInfo
.
getTypeInfo
(
valueType
));
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论