Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
068a62eb
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
068a62eb
编写于
3月 25, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PG: table DDL fix
上级
78bdd684
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
23 addition
and
34 deletion
+23
-34
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/SQLSourceViewer.java
...src/org/jkiss/dbeaver/ui/editors/sql/SQLSourceViewer.java
+7
-7
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreTableManager.java
...kiss/dbeaver/ext/postgresql/edit/PostgreTableManager.java
+1
-7
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreTableManagerBase.java
.../dbeaver/ext/postgresql/edit/PostgreTableManagerBase.java
+11
-11
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
...jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
+1
-7
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/ui/editors/PostgreSourceViewEditor.java
...er/ext/postgresql/ui/editors/PostgreSourceViewEditor.java
+1
-2
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPScriptObject.java
...er.model/src/org/jkiss/dbeaver/model/DBPScriptObject.java
+2
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/sql/SQLSourceViewer.java
浏览文件 @
068a62eb
...
...
@@ -62,13 +62,13 @@ public class SQLSourceViewer<T extends DBPScriptObject & DBSObject> extends SQLE
protected
Map
<
String
,
Object
>
getSourceOptions
()
{
IDatabaseEditorInput
editorInput
=
getEditorInput
();
Collection
<
String
>
attributeNames
=
editorInput
.
getAttributeNames
();
if
(
attributeNames
.
isEmpty
())
{
return
DBPScriptObject
.
EMPTY_OPTIONS
;
}
Map
<
String
,
Object
>
options
=
new
HashMap
<
String
,
Object
>();
for
(
String
name
:
attributeNames
)
{
Object
attribute
=
editorInput
.
getAttribute
(
nam
e
);
options
.
put
(
name
,
attribute
);
Map
<
String
,
Object
>
options
=
new
HashMap
<>();
options
.
put
(
DBPScriptObject
.
OPTION_DDL_SOURCE
,
true
)
;
if
(!
attributeNames
.
isEmpty
())
{
for
(
String
name
:
attributeNames
)
{
Object
attribute
=
editorInput
.
getAttribute
(
name
);
options
.
put
(
name
,
attribut
e
);
}
}
return
options
;
}
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreTableManager.java
浏览文件 @
068a62eb
...
...
@@ -27,7 +27,6 @@ import org.jkiss.dbeaver.model.edit.DBEObjectRenamer;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.impl.DBSObjectCache
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager
;
import
org.jkiss.dbeaver.model.messages.ModelMessages
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
...
...
@@ -39,7 +38,7 @@ import java.util.Map;
/**
* Postgre table manager
*/
public
class
PostgreTableManager
extends
SQLTableManager
<
PostgreTableBase
,
PostgreSchema
>
implements
DBEObjectRenamer
<
PostgreTableBase
>
{
public
class
PostgreTableManager
extends
PostgreTableManagerBase
implements
DBEObjectRenamer
<
PostgreTableBase
>
{
private
static
final
Class
<?>[]
CHILD_TYPES
=
{
PostgreTableColumn
.
class
,
...
...
@@ -82,11 +81,6 @@ public class PostgreTableManager extends SQLTableManager<PostgreTableBase, Postg
}
}
@Override
protected
void
addObjectExtraActions
(
List
<
DBEPersistAction
>
actions
,
NestedObjectCommand
<
PostgreTableBase
,
PropertyHandler
>
command
,
Map
<
String
,
Object
>
options
)
{
PostgreDDLUtils
.
addObjectExtraActions
(
actions
,
command
.
getObject
(),
options
);
}
@Override
protected
void
appendTableModifiers
(
PostgreTableBase
tableBase
,
NestedObjectCommand
tableProps
,
StringBuilder
ddl
)
{
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/Postgre
DDLUtils
.java
→
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/Postgre
TableManagerBase
.java
浏览文件 @
068a62eb
...
...
@@ -17,14 +17,16 @@
package
org.jkiss.dbeaver.ext.postgresql.edit
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreConstants
;
import
org.jkiss.dbeaver.ext.postgresql.model.*
;
import
org.jkiss.dbeaver.model.DBConstants
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBPScriptObject
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistActionComment
;
import
org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
...
...
@@ -38,13 +40,13 @@ import java.util.Map;
/**
* Postgre table manager
*/
public
class
PostgreDDLUtils
{
public
abstract
class
PostgreTableManagerBase
extends
SQLTableManager
<
PostgreTableBase
,
PostgreSchema
>
{
protected
static
final
Log
log
=
Log
.
getLog
(
PostgreDDLUtils
.
class
);
static
void
addObjectExtraActions
(
List
<
DBEPersistAction
>
actions
,
PostgreTableBase
table
,
Map
<
String
,
Object
>
options
)
{
protected
void
addObjectExtraActions
(
List
<
DBEPersistAction
>
actions
,
NestedObjectCommand
<
PostgreTableBase
,
PropertyHandler
>
command
,
Map
<
String
,
Object
>
options
)
{
boolean
isDDL
=
CommonUtils
.
getOption
(
options
,
DBPScriptObject
.
OPTION_DDL_SOURCE
);
PostgreTableBase
table
=
command
.
getObject
();
// Add comments
if
(
!
CommonUtils
.
isEmpty
(
table
.
getDescription
())
)
{
if
(
(!
table
.
isPersisted
()
||
command
.
getProperty
(
DBConstants
.
PROP_ID_DESCRIPTION
)
!=
null
)
&&
table
.
getDescription
()
!=
null
)
{
actions
.
add
(
new
SQLDatabasePersistAction
(
"Comment table"
,
"COMMENT ON "
+
(
table
.
isView
()
?
"VIEW"
:
"TABLE"
)
+
" "
+
table
.
getFullyQualifiedName
(
DBPEvaluationContext
.
DDL
)
+
...
...
@@ -52,7 +54,7 @@ public class PostgreDDLUtils {
}
DBRProgressMonitor
monitor
=
new
VoidProgressMonitor
();
try
{
{
if
(
isDDL
)
{
// Column comments
boolean
hasComments
=
false
;
for
(
PostgreTableColumn
column
:
table
.
getAttributes
(
monitor
))
{
...
...
@@ -69,7 +71,7 @@ public class PostgreDDLUtils {
}
// Triggers
if
(
table
instanceof
PostgreTableReal
)
{
if
(
isDDL
&&
table
instanceof
PostgreTableReal
)
{
Collection
<
PostgreTrigger
>
triggers
=
((
PostgreTableReal
)
table
).
getTriggers
(
monitor
);
if
(!
CommonUtils
.
isEmpty
(
triggers
))
{
actions
.
add
(
new
SQLDatabasePersistActionComment
(
table
.
getDataSource
(),
"Table Triggers"
));
...
...
@@ -80,8 +82,7 @@ public class PostgreDDLUtils {
}
}
if
(
CommonUtils
.
getOption
(
options
,
PostgreConstants
.
OPTION_DDL_SHOW_PERMISSIONS
))
{
if
(
isDDL
&&
CommonUtils
.
getOption
(
options
,
PostgreConstants
.
OPTION_DDL_SHOW_PERMISSIONS
))
{
// Permissions
Collection
<
PostgrePermission
>
permissions
=
table
.
getPermissions
(
monitor
);
if
(!
CommonUtils
.
isEmpty
(
permissions
))
{
...
...
@@ -102,5 +103,4 @@ public class PostgreDDLUtils {
log
.
error
(
e
);
}
}
}
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
浏览文件 @
068a62eb
...
...
@@ -25,7 +25,6 @@ import org.jkiss.dbeaver.model.edit.DBECommandContext;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.impl.DBSObjectCache
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -36,7 +35,7 @@ import java.util.Map;
/**
* PostgreViewManager
*/
public
class
PostgreViewManager
extends
SQLTableManager
<
PostgreTableBase
,
PostgreSchema
>
{
public
class
PostgreViewManager
extends
PostgreTableManagerBase
{
private
static
final
Class
<?>[]
CHILD_TYPES
=
{
PostgreTableColumn
.
class
,
...
...
@@ -102,11 +101,6 @@ public class PostgreViewManager extends SQLTableManager<PostgreTableBase, Postgr
);
}
@Override
protected
void
addObjectExtraActions
(
List
<
DBEPersistAction
>
actions
,
NestedObjectCommand
<
PostgreTableBase
,
PropertyHandler
>
command
,
Map
<
String
,
Object
>
options
)
{
PostgreDDLUtils
.
addObjectExtraActions
(
actions
,
command
.
getObject
(),
options
);
}
protected
void
createOrReplaceViewQuery
(
List
<
DBEPersistAction
>
actions
,
PostgreViewBase
view
)
{
String
sql
=
view
.
getSource
().
trim
();
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/ui/editors/PostgreSourceViewEditor.java
浏览文件 @
068a62eb
...
...
@@ -125,11 +125,10 @@ public class PostgreSourceViewEditor extends SQLSourceViewer<PostgreScriptObject
@Override
protected
Map
<
String
,
Object
>
getSourceOptions
()
{
Map
<
String
,
Object
>
options
=
new
HashMap
<>
();
Map
<
String
,
Object
>
options
=
super
.
getSourceOptions
();
options
.
put
(
DBPScriptObject
.
OPTION_DEBUGGER_SOURCE
,
omitHeader
);
options
.
put
(
PostgreConstants
.
OPTION_DDL_SHOW_PERMISSIONS
,
showPermissions
);
options
.
put
(
PostgreConstants
.
OPTION_DDL_SHOW_COLUMN_COMMENTS
,
showColumnComments
);
options
.
putAll
(
super
.
getSourceOptions
());
return
options
;
}
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPScriptObject.java
浏览文件 @
068a62eb
...
...
@@ -36,6 +36,8 @@ public interface DBPScriptObject extends DBPObject {
String
OPTION_SCRIPT_FORMAT
=
"script.format"
;
String
OPTION_SCRIPT_FORMAT_COMPACT
=
"script.format.compact"
;
String
OPTION_DDL_SOURCE
=
"ddl.source"
;
// Extracts object source for debugger
// By defautl the same as regular source but in some cases source should be transormed (e.g. for PG)
String
OPTION_DEBUGGER_SOURCE
=
"debugger.source"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录