Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f592e317
提交
f592e317
authored
11月 06, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Expression.getUnenclosedSQL(StringBuilder)
上级
d0ecd064
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
52 行增加
和
36 行删除
+52
-36
Delete.java
h2/src/main/org/h2/command/dml/Delete.java
+4
-5
Select.java
h2/src/main/org/h2/command/dml/Select.java
+10
-10
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+2
-3
Update.java
h2/src/main/org/h2/command/dml/Update.java
+4
-4
Expression.java
h2/src/main/org/h2/expression/Expression.java
+20
-2
Window.java
h2/src/main/org/h2/expression/aggregate/Window.java
+1
-2
SortOrder.java
h2/src/main/org/h2/result/SortOrder.java
+9
-8
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+2
-2
没有找到文件。
h2/src/main/org/h2/command/dml/Delete.java
浏览文件 @
f592e317
...
...
@@ -20,7 +20,6 @@ import org.h2.result.RowList;
import
org.h2.table.PlanItem
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -140,12 +139,12 @@ public class Delete extends Prepared {
buff
.
append
(
"DELETE "
);
buff
.
append
(
"FROM "
).
append
(
targetTableFilter
.
getPlanSQL
(
false
));
if
(
condition
!=
null
)
{
buff
.
append
(
"\nWHERE "
)
.
append
(
StringUtils
.
unEnclose
(
condition
.
getSQL
())
);
buff
.
append
(
"\nWHERE "
)
;
condition
.
getUnenclosedSQL
(
buff
);
}
if
(
limitExpr
!=
null
)
{
buff
.
append
(
"\nLIMIT ("
)
.
append
(
StringUtils
.
unEnclose
(
limitExpr
.
getSQL
())
).
append
(
')'
);
buff
.
append
(
"\nLIMIT ("
)
;
limitExpr
.
getUnenclosedSQL
(
buff
).
append
(
')'
);
}
return
buff
.
toString
();
}
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
f592e317
...
...
@@ -1360,8 +1360,8 @@ public class Select extends Query {
}
}
if
(
condition
!=
null
)
{
buff
.
append
(
"\nWHERE "
)
.
append
(
StringUtils
.
unEnclose
(
condition
.
getSQL
()
));
buff
.
append
(
"\nWHERE "
)
;
condition
.
getUnenclosedSQL
(
buff
.
builder
(
));
}
if
(
groupIndex
!=
null
)
{
buff
.
append
(
"\nGROUP BY "
);
...
...
@@ -1370,7 +1370,7 @@ public class Select extends Query {
Expression
g
=
exprList
[
gi
];
g
=
g
.
getNonAliasExpression
();
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
StringUtils
.
unEnclose
(
g
.
getSQL
()
));
g
.
getUnenclosedSQL
(
buff
.
builder
(
));
}
}
if
(
group
!=
null
)
{
...
...
@@ -1378,7 +1378,7 @@ public class Select extends Query {
buff
.
resetCount
();
for
(
Expression
g
:
group
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
StringUtils
.
unEnclose
(
g
.
getSQL
()
));
g
.
getUnenclosedSQL
(
buff
.
builder
(
));
}
}
if
(
having
!=
null
)
{
...
...
@@ -1386,12 +1386,12 @@ public class Select extends Query {
// in this case the query is not run directly, just getPlanSQL is
// called
Expression
h
=
having
;
buff
.
append
(
"\nHAVING "
)
.
append
(
StringUtils
.
unEnclose
(
h
.
getSQL
()
));
buff
.
append
(
"\nHAVING "
)
;
h
.
getUnenclosedSQL
(
buff
.
builder
(
));
}
else
if
(
havingIndex
>=
0
)
{
Expression
h
=
exprList
[
havingIndex
];
buff
.
append
(
"\nHAVING "
)
.
append
(
StringUtils
.
unEnclose
(
h
.
getSQL
()
));
buff
.
append
(
"\nHAVING "
)
;
h
.
getUnenclosedSQL
(
buff
.
builder
(
));
}
if
(
sort
!=
null
)
{
buff
.
append
(
"\nORDER BY "
).
append
(
...
...
@@ -1407,8 +1407,8 @@ public class Select extends Query {
}
appendLimitToSQL
(
buff
.
builder
());
if
(
sampleSizeExpr
!=
null
)
{
buff
.
append
(
"\nSAMPLE_SIZE "
)
.
append
(
StringUtils
.
unEnclose
(
sampleSizeExpr
.
getSQL
()
));
buff
.
append
(
"\nSAMPLE_SIZE "
)
;
sampleSizeExpr
.
getUnenclosedSQL
(
buff
.
builder
(
));
}
if
(
isForUpdate
)
{
buff
.
append
(
"\nFOR UPDATE"
);
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
f592e317
...
...
@@ -28,7 +28,6 @@ import org.h2.table.ColumnResolver;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.ColumnNamer
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueNull
;
...
...
@@ -429,8 +428,8 @@ public class SelectUnion extends Query {
}
appendLimitToSQL
(
buff
);
if
(
sampleSizeExpr
!=
null
)
{
buff
.
append
(
"\nSAMPLE_SIZE "
)
.
append
(
StringUtils
.
unEnclose
(
sampleSizeExpr
.
getSQL
())
);
buff
.
append
(
"\nSAMPLE_SIZE "
)
;
sampleSizeExpr
.
getUnenclosedSQL
(
buff
);
}
if
(
isForUpdate
)
{
buff
.
append
(
"\nFOR UPDATE"
);
...
...
h2/src/main/org/h2/command/dml/Update.java
浏览文件 @
f592e317
...
...
@@ -28,7 +28,6 @@ import org.h2.table.PlanItem;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -226,11 +225,12 @@ public class Update extends Prepared {
e
.
getSQL
(
buff
.
builder
());
}
if
(
condition
!=
null
)
{
buff
.
append
(
"\nWHERE "
).
append
(
StringUtils
.
unEnclose
(
condition
.
getSQL
()));
buff
.
append
(
"\nWHERE "
);
condition
.
getUnenclosedSQL
(
buff
.
builder
());
}
if
(
limitExpr
!=
null
)
{
buff
.
append
(
"\nLIMIT "
)
.
append
(
StringUtils
.
unEnclose
(
limitExpr
.
getSQL
()
));
buff
.
append
(
"\nLIMIT "
)
;
limitExpr
.
getUnenclosedSQL
(
buff
.
builder
(
));
}
return
buff
.
toString
();
}
...
...
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
f592e317
...
...
@@ -11,7 +11,6 @@ import org.h2.result.ResultInterface;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
...
...
@@ -125,6 +124,25 @@ public abstract class Expression {
*/
public
abstract
StringBuilder
getSQL
(
StringBuilder
builder
);
/**
* Appends the SQL statement of this expression to the specified builder.
* This may not always be the original SQL statement, specially after
* optimization. Enclosing '(' and ')' are removed.
*
* @param builder
* string builder
* @return the specified string builder
*/
public
StringBuilder
getUnenclosedSQL
(
StringBuilder
builder
)
{
int
first
=
builder
.
length
();
int
last
=
getSQL
(
builder
).
length
()
-
1
;
if
(
last
>
first
&&
builder
.
charAt
(
first
)
==
'('
&&
builder
.
charAt
(
last
)
==
')'
)
{
builder
.
setLength
(
last
);
builder
.
deleteCharAt
(
first
);
}
return
builder
;
}
/**
* Update an aggregate value. This method is called at statement execution
* time. It is usually called once for each row, but if the expression is
...
...
@@ -281,7 +299,7 @@ public abstract class Expression {
* @return the alias name
*/
public
String
getAlias
()
{
return
StringUtils
.
unEnclose
(
getSQL
()
);
return
getUnenclosedSQL
(
new
StringBuilder
()).
toString
(
);
}
/**
...
...
h2/src/main/org/h2/expression/aggregate/Window.java
浏览文件 @
f592e317
...
...
@@ -15,7 +15,6 @@ import org.h2.message.DbException;
import
org.h2.result.SortOrder
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
...
...
@@ -220,7 +219,7 @@ public final class Window {
if
(
i
>
0
)
{
builder
.
append
(
", "
);
}
builder
.
append
(
StringUtils
.
unEnclose
(
partitionBy
.
get
(
i
).
getSQL
())
);
partitionBy
.
get
(
i
).
getUnenclosedSQL
(
builder
);
}
}
appendOrderBy
(
builder
,
orderBy
);
...
...
h2/src/main/org/h2/result/SortOrder.java
浏览文件 @
f592e317
...
...
@@ -12,8 +12,6 @@ import org.h2.expression.Expression;
import
org.h2.expression.ExpressionColumn
;
import
org.h2.table.Column
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -118,18 +116,21 @@ public class SortOrder implements Comparator<Value[]> {
* @return the SQL snippet
*/
public
String
getSQL
(
Expression
[]
list
,
int
visible
)
{
St
atementBuilder
buff
=
new
Statement
Builder
();
St
ringBuilder
builder
=
new
String
Builder
();
int
i
=
0
;
for
(
int
idx
:
queryColumnIndexes
)
{
buff
.
appendExceptFirst
(
", "
);
if
(
i
>
0
)
{
builder
.
append
(
", "
);
}
if
(
idx
<
visible
)
{
bu
ff
.
append
(
idx
+
1
);
bu
ilder
.
append
(
idx
+
1
);
}
else
{
buff
.
append
(
'='
).
append
(
StringUtils
.
unEnclose
(
list
[
idx
].
getSQL
()));
builder
.
append
(
'='
);
list
[
idx
].
getUnenclosedSQL
(
builder
);
}
typeToString
(
bu
ff
.
builder
()
,
sortTypes
[
i
++]);
typeToString
(
bu
ilder
,
sortTypes
[
i
++]);
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
/**
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
f592e317
...
...
@@ -785,7 +785,7 @@ public class TableFilter implements ColumnResolver {
// otherwise the nesting is unclear
buff
.
append
(
"1=1"
);
}
else
{
buff
.
append
(
StringUtils
.
unEnclose
(
joinCondition
.
getSQL
())
);
joinCondition
.
getUnenclosedSQL
(
buff
);
}
}
return
buff
.
toString
();
...
...
@@ -851,7 +851,7 @@ public class TableFilter implements ColumnResolver {
// unclear
buff
.
append
(
"1=1"
);
}
else
{
buff
.
append
(
StringUtils
.
unEnclose
(
joinCondition
.
getSQL
())
);
joinCondition
.
getUnenclosedSQL
(
buff
);
}
}
if
(
filterCondition
!=
null
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论