Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
f177d0de
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
f177d0de
编写于
5月 08, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3398 PG comments DDL fix
Former-commit-id:
8c67b694
上级
6fea9ded
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
67 addition
and
14 deletion
+67
-14
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java
...src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java
+9
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/properties/ObjectPropertiesEditor.java
.../ui/editors/entity/properties/ObjectPropertiesEditor.java
+3
-1
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreTableManagerBase.java
.../dbeaver/ext/postgresql/edit/PostgreTableManagerBase.java
+3
-1
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
...jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
+17
-8
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreViewBase.java
...g/jkiss/dbeaver/ext/postgresql/model/PostgreViewBase.java
+32
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPScriptObject.java
...er.model/src/org/jkiss/dbeaver/model/DBPScriptObject.java
+3
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java
浏览文件 @
f177d0de
...
@@ -232,7 +232,9 @@ public class EntityEditor extends MultiPageDatabaseEditor
...
@@ -232,7 +232,9 @@ public class EntityEditor extends MultiPageDatabaseEditor
// Flush all nested object editors and result containers
// Flush all nested object editors and result containers
for
(
IEditorPart
editor
:
editorMap
.
values
())
{
for
(
IEditorPart
editor
:
editorMap
.
values
())
{
if
(
editor
instanceof
ObjectPropertiesEditor
||
editor
instanceof
IResultSetContainer
)
{
if
(
editor
instanceof
ObjectPropertiesEditor
||
editor
instanceof
IResultSetContainer
)
{
editor
.
doSave
(
monitor
);
if
(
editor
.
isDirty
())
{
editor
.
doSave
(
monitor
);
}
}
}
if
(
monitor
.
isCanceled
())
{
if
(
monitor
.
isCanceled
())
{
return
;
return
;
...
@@ -418,9 +420,11 @@ public class EntityEditor extends MultiPageDatabaseEditor
...
@@ -418,9 +420,11 @@ public class EntityEditor extends MultiPageDatabaseEditor
DBeaverUI
.
syncExec
(()
->
DBUserInterface
.
getInstance
().
showError
(
"Validation"
,
e
.
getMessage
()));
DBeaverUI
.
syncExec
(()
->
DBUserInterface
.
getInstance
().
showError
(
"Validation"
,
e
.
getMessage
()));
return
IDialogConstants
.
CANCEL_ID
;
return
IDialogConstants
.
CANCEL_ID
;
}
}
Map
<
String
,
Object
>
options
=
new
HashMap
<>();
options
.
put
(
DBPScriptObject
.
OPTION_OBJECT_SAVE
,
true
);
script
.
append
(
SQLUtils
.
generateScript
(
script
.
append
(
SQLUtils
.
generateScript
(
commandContext
.
getExecutionContext
().
getDataSource
(),
commandContext
.
getExecutionContext
().
getDataSource
(),
command
.
getPersistActions
(
DBPScriptObject
.
EMPTY_OPTIONS
),
command
.
getPersistActions
(
options
),
false
));
false
));
}
}
if
(
script
.
length
()
==
0
)
{
if
(
script
.
length
()
==
0
)
{
...
@@ -945,7 +949,9 @@ public class EntityEditor extends MultiPageDatabaseEditor
...
@@ -945,7 +949,9 @@ public class EntityEditor extends MultiPageDatabaseEditor
try
{
try
{
final
DBECommandContext
commandContext
=
getCommandContext
();
final
DBECommandContext
commandContext
=
getCommandContext
();
if
(
commandContext
!=
null
&&
commandContext
.
isDirty
())
{
if
(
commandContext
!=
null
&&
commandContext
.
isDirty
())
{
success
=
saveCommandContext
(
monitor
,
DBPScriptObject
.
EMPTY_OPTIONS
);
Map
<
String
,
Object
>
options
=
new
HashMap
<>();
options
.
put
(
DBPScriptObject
.
OPTION_OBJECT_SAVE
,
true
);
success
=
saveCommandContext
(
monitor
,
options
);
}
else
{
}
else
{
success
=
true
;
success
=
true
;
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/properties/ObjectPropertiesEditor.java
浏览文件 @
f177d0de
...
@@ -293,7 +293,9 @@ public class ObjectPropertiesEditor extends AbstractDatabaseObjectEditor<DBSObje
...
@@ -293,7 +293,9 @@ public class ObjectPropertiesEditor extends AbstractDatabaseObjectEditor<DBSObje
public
void
doSave
(
IProgressMonitor
monitor
)
public
void
doSave
(
IProgressMonitor
monitor
)
{
{
for
(
ISaveablePart
sp
:
nestedSaveable
)
{
for
(
ISaveablePart
sp
:
nestedSaveable
)
{
sp
.
doSave
(
monitor
);
if
(
sp
.
isDirty
())
{
sp
.
doSave
(
monitor
);
}
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreTableManagerBase.java
浏览文件 @
f177d0de
...
@@ -53,7 +53,9 @@ public abstract class PostgreTableManagerBase extends SQLTableManager<PostgreTab
...
@@ -53,7 +53,9 @@ public abstract class PostgreTableManagerBase extends SQLTableManager<PostgreTab
}
else
{
}
else
{
comment
=
table
.
getDescription
();
comment
=
table
.
getDescription
();
}
}
boolean
showComments
=
CommonUtils
.
getOption
(
options
,
PostgreConstants
.
OPTION_DDL_SHOW_COLUMN_COMMENTS
);
boolean
showComments
=
CommonUtils
.
getOption
(
options
,
PostgreConstants
.
OPTION_DDL_SHOW_COLUMN_COMMENTS
)
||
CommonUtils
.
getOption
(
options
,
DBPScriptObject
.
OPTION_OBJECT_SAVE
);
if
(
showComments
&&
comment
!=
null
)
{
if
(
showComments
&&
comment
!=
null
)
{
actions
.
add
(
new
SQLDatabasePersistAction
(
actions
.
add
(
new
SQLDatabasePersistAction
(
"Comment table"
,
"Comment table"
,
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
浏览文件 @
f177d0de
...
@@ -18,16 +18,25 @@ package org.jkiss.dbeaver.ext.postgresql.edit;
...
@@ -18,16 +18,25 @@ package org.jkiss.dbeaver.ext.postgresql.edit;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreConstants
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreUtils
;
import
org.jkiss.dbeaver.ext.postgresql.model.*
;
import
org.jkiss.dbeaver.ext.postgresql.model.*
;
import
org.jkiss.dbeaver.model.DBConstants
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBPScriptObject
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.edit.DBECommandContext
;
import
org.jkiss.dbeaver.model.edit.DBECommandContext
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.impl.DBSObjectCache
;
import
org.jkiss.dbeaver.model.impl.DBSObjectCache
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistActionComment
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAssociation
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -61,9 +70,6 @@ public class PostgreViewManager extends PostgreTableManagerBase {
...
@@ -61,9 +70,6 @@ public class PostgreViewManager extends PostgreTableManagerBase {
if
(
CommonUtils
.
isEmpty
(
object
.
getName
()))
{
if
(
CommonUtils
.
isEmpty
(
object
.
getName
()))
{
throw
new
DBException
(
"View name cannot be empty"
);
throw
new
DBException
(
"View name cannot be empty"
);
}
}
if
(
CommonUtils
.
isEmpty
(((
PostgreViewBase
)
object
).
getSource
()))
{
throw
new
DBException
(
"View definition cannot be empty"
);
}
}
}
@Override
@Override
...
@@ -103,12 +109,15 @@ public class PostgreViewManager extends PostgreTableManagerBase {
...
@@ -103,12 +109,15 @@ public class PostgreViewManager extends PostgreTableManagerBase {
protected
void
createOrReplaceViewQuery
(
List
<
DBEPersistAction
>
actions
,
PostgreViewBase
view
)
protected
void
createOrReplaceViewQuery
(
List
<
DBEPersistAction
>
actions
,
PostgreViewBase
view
)
{
{
String
sql
=
view
.
getSource
().
trim
();
if
(!
CommonUtils
.
isEmpty
(
view
.
getSource
()))
{
if
(!
sql
.
toLowerCase
(
Locale
.
ENGLISH
).
startsWith
(
"create"
))
{
// Source may be empty if it wasn't yet read. Then it definitely wasn't changed
sql
=
"CREATE OR REPLACE VIEW "
+
DBUtils
.
getObjectFullName
(
view
,
DBPEvaluationContext
.
DDL
)
+
" AS\n"
+
sql
;
String
sql
=
view
.
getSource
().
trim
();
if
(!
sql
.
toLowerCase
(
Locale
.
ENGLISH
).
startsWith
(
"create"
))
{
sql
=
"CREATE OR REPLACE VIEW "
+
DBUtils
.
getObjectFullName
(
view
,
DBPEvaluationContext
.
DDL
)
+
" AS\n"
+
sql
;
}
actions
.
add
(
new
SQLDatabasePersistAction
(
"Create view"
,
sql
));
}
}
actions
.
add
(
new
SQLDatabasePersistAction
(
"Create view"
,
sql
));
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreViewBase.java
浏览文件 @
f177d0de
...
@@ -18,18 +18,27 @@ package org.jkiss.dbeaver.ext.postgresql.model;
...
@@ -18,18 +18,27 @@ package org.jkiss.dbeaver.ext.postgresql.model;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreConstants
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreUtils
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreUtils
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer
;
import
org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.meta.Property
;
import
org.jkiss.dbeaver.model.meta.Property
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex
;
import
org.jkiss.utils.CommonUtils
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -95,7 +104,24 @@ public abstract class PostgreViewBase extends PostgreTableReal
...
@@ -95,7 +104,24 @@ public abstract class PostgreViewBase extends PostgreTableReal
source
=
""
;
source
=
""
;
}
}
}
}
return
source
;
List
<
DBEPersistAction
>
actions
=
new
ArrayList
<>();
if
(
CommonUtils
.
getOption
(
options
,
PostgreConstants
.
OPTION_DDL_SHOW_COLUMN_COMMENTS
)
&&
getDescription
()
!=
null
)
{
actions
.
add
(
new
SQLDatabasePersistAction
(
"Comment"
,
"COMMENT ON VIEW "
+
getFullyQualifiedName
(
DBPEvaluationContext
.
DDL
)
+
" IS "
+
SQLUtils
.
quoteString
(
this
,
getDescription
())));
}
if
(
CommonUtils
.
getOption
(
options
,
PostgreConstants
.
OPTION_DDL_SHOW_PERMISSIONS
))
{
PostgreUtils
.
getObjectGrantPermissionActions
(
monitor
,
this
,
actions
,
options
);
}
StringBuilder
ddl
=
new
StringBuilder
(
source
);
if
(!
actions
.
isEmpty
())
{
ddl
.
append
(
"\n\n"
).
append
(
SQLUtils
.
generateScript
(
getDataSource
(),
actions
.
toArray
(
new
DBEPersistAction
[
actions
.
size
()]),
false
));
}
return
ddl
.
toString
();
}
}
protected
String
readExtraDefinition
(
JDBCSession
session
,
Map
<
String
,
Object
>
options
)
throws
DBException
{
protected
String
readExtraDefinition
(
JDBCSession
session
,
Map
<
String
,
Object
>
options
)
throws
DBException
{
...
@@ -110,4 +136,9 @@ public abstract class PostgreViewBase extends PostgreTableReal
...
@@ -110,4 +136,9 @@ public abstract class PostgreViewBase extends PostgreTableReal
public
abstract
String
getViewType
();
public
abstract
String
getViewType
();
@Override
public
DBSObject
refreshObject
(
DBRProgressMonitor
monitor
)
throws
DBException
{
this
.
source
=
null
;
return
super
.
refreshObject
(
monitor
);
}
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBPScriptObject.java
浏览文件 @
f177d0de
...
@@ -46,6 +46,9 @@ public interface DBPScriptObject extends DBPObject {
...
@@ -46,6 +46,9 @@ public interface DBPScriptObject extends DBPObject {
// nested objects (columns, constraints, etc) which can be embedded in parent object declaration (tables)
// nested objects (columns, constraints, etc) which can be embedded in parent object declaration (tables)
String
OPTION_EMBEDDED_SOURCE
=
"embedded.source"
;
String
OPTION_EMBEDDED_SOURCE
=
"embedded.source"
;
// Means that result script will be used for object save
String
OPTION_OBJECT_SAVE
=
"object.save"
;
Map
<
String
,
Object
>
EMPTY_OPTIONS
=
Collections
.
unmodifiableMap
(
new
HashMap
<>());
Map
<
String
,
Object
>
EMPTY_OPTIONS
=
Collections
.
unmodifiableMap
(
new
HashMap
<>());
String
getObjectDefinitionText
(
DBRProgressMonitor
monitor
,
Map
<
String
,
Object
>
options
)
String
getObjectDefinitionText
(
DBRProgressMonitor
monitor
,
Map
<
String
,
Object
>
options
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录