Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一剑流云
dbeaver
提交
574774ee
D
dbeaver
项目概览
一剑流云
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
574774ee
编写于
1月 11, 2017
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#1140 Use virtual unique key in resulset SQL generator.
上级
b0e65bc8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
22 deletion
+25
-22
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/generator/GenerateSQLContributor.java
...aver/ui/editors/sql/generator/GenerateSQLContributor.java
+25
-22
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/generator/GenerateSQLContributor.java
浏览文件 @
574774ee
...
...
@@ -32,6 +32,7 @@ import org.jkiss.dbeaver.Log;
import
org.jkiss.dbeaver.core.DBeaverUI
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.data.DBDRowIdentifier
;
import
org.jkiss.dbeaver.model.navigator.DBNDatabaseNode
;
import
org.jkiss.dbeaver.model.navigator.DBNNode
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
...
...
@@ -154,7 +155,7 @@ public class GenerateSQLContributor extends CompoundContributionItem {
{
for
(
ResultSetRow
firstRow
:
selectedRows
)
{
Collection
<
?
extends
DBSEntityAttribute
>
keyAttributes
=
getKeyAttributes
(
monitor
,
object
);
Collection
<
DBDAttributeBinding
>
keyAttributes
=
getKeyAttributes
(
monitor
,
object
);
sql
.
append
(
"SELECT "
);
boolean
hasAttr
=
false
;
for
(
DBSAttributeBase
attr
:
getValueAttributes
(
monitor
,
object
,
keyAttributes
))
{
...
...
@@ -165,15 +166,10 @@ public class GenerateSQLContributor extends CompoundContributionItem {
sql
.
append
(
"\nFROM "
).
append
(
DBUtils
.
getObjectFullName
(
entity
,
DBPEvaluationContext
.
DML
));
sql
.
append
(
"\nWHERE "
);
hasAttr
=
false
;
for
(
DB
SEntityAttribute
attr
:
keyAttributes
)
{
for
(
DB
DAttributeBinding
binding
:
keyAttributes
)
{
if
(
hasAttr
)
sql
.
append
(
" AND "
);
DBDAttributeBinding
binding
=
rsv
.
getModel
().
getAttributeBinding
(
attr
);
sql
.
append
(
DBUtils
.
getObjectFullName
(
attr
,
DBPEvaluationContext
.
DML
)).
append
(
"="
);
if
(
binding
==
null
)
{
appendDefaultValue
(
sql
,
attr
);
}
else
{
appendAttributeValue
(
rsv
,
sql
,
binding
,
firstRow
);
}
sql
.
append
(
DBUtils
.
getObjectFullName
(
binding
.
getAttribute
(),
DBPEvaluationContext
.
DML
)).
append
(
"="
);
appendAttributeValue
(
rsv
,
sql
,
binding
,
firstRow
);
hasAttr
=
true
;
}
sql
.
append
(
";\n"
);
...
...
@@ -223,19 +219,14 @@ public class GenerateSQLContributor extends CompoundContributionItem {
{
for
(
ResultSetRow
firstRow
:
selectedRows
)
{
Collection
<
?
extends
DBSEntityAttribute
>
keyAttributes
=
getKeyAttributes
(
monitor
,
object
);
Collection
<
DBDAttributeBinding
>
keyAttributes
=
getKeyAttributes
(
monitor
,
object
);
sql
.
append
(
"DELETE FROM "
).
append
(
DBUtils
.
getObjectFullName
(
entity
,
DBPEvaluationContext
.
DML
));
sql
.
append
(
"\nWHERE "
);
boolean
hasAttr
=
false
;
for
(
DB
SEntityAttribute
attr
:
keyAttributes
)
{
for
(
DB
DAttributeBinding
binding
:
keyAttributes
)
{
if
(
hasAttr
)
sql
.
append
(
" AND "
);
DBDAttributeBinding
binding
=
rsv
.
getModel
().
getAttributeBinding
(
attr
);
sql
.
append
(
DBUtils
.
getObjectFullName
(
attr
,
DBPEvaluationContext
.
DML
)).
append
(
"="
);
if
(
binding
==
null
)
{
appendDefaultValue
(
sql
,
attr
);
}
else
{
appendAttributeValue
(
rsv
,
sql
,
binding
,
firstRow
);
}
sql
.
append
(
DBUtils
.
getObjectFullName
(
binding
.
getAttribute
(),
DBPEvaluationContext
.
DML
)).
append
(
"="
);
appendAttributeValue
(
rsv
,
sql
,
binding
,
firstRow
);
hasAttr
=
true
;
}
sql
.
append
(
";\n"
);
...
...
@@ -379,14 +370,26 @@ public class GenerateSQLContributor extends CompoundContributionItem {
return
object
.
getVisibleAttributes
();
}
protected
Collection
<?
extends
DBSEntityAttribute
>
getKeyAttributes
(
DBRProgressMonitor
monitor
,
ResultSetModel
object
)
throws
DBException
protected
List
<
DBDAttributeBinding
>
getKeyAttributes
(
DBRProgressMonitor
monitor
,
ResultSetModel
object
)
throws
DBException
{
final
DB
SEntity
singleSource
=
object
.
getSingleSource
(
);
if
(
singleSource
==
null
)
{
final
DB
DRowIdentifier
rowIdentifier
=
getDefaultRowIdentifier
(
object
);
if
(
rowIdentifier
==
null
)
{
return
Collections
.
emptyList
();
}
return
DBUtils
.
getBestTableIdentifier
(
monitor
,
singleSource
);
return
rowIdentifier
.
getAttributes
(
);
}
@Nullable
private
DBDRowIdentifier
getDefaultRowIdentifier
(
ResultSetModel
object
)
{
for
(
DBDAttributeBinding
attr
:
object
.
getAttributes
())
{
DBDRowIdentifier
rowIdentifier
=
attr
.
getRowIdentifier
();
if
(
rowIdentifier
!=
null
)
{
return
rowIdentifier
;
}
}
return
null
;
}
}
private
static
ContributionItem
makeAction
(
String
text
,
final
DBRRunnableWithResult
<
String
>
runnable
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录