Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
a31179de
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,发现更多精彩内容 >>
提交
a31179de
编写于
5月 23, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#2756 Vertica: column editor
上级
aa43c9da
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
159 addition
and
6 deletion
+159
-6
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreTableColumnManager.java
...beaver/ext/postgresql/edit/PostgreTableColumnManager.java
+3
-3
plugins/org.jkiss.dbeaver.ext.vertica/plugin.xml
plugins/org.jkiss.dbeaver.ext.vertica/plugin.xml
+7
-0
plugins/org.jkiss.dbeaver.ext.vertica/src/org/jkiss/dbeaver/ext/vertica/edit/VerticaTableColumnManager.java
...s/dbeaver/ext/vertica/edit/VerticaTableColumnManager.java
+113
-0
plugins/org.jkiss.dbeaver.ext.vertica/src/org/jkiss/dbeaver/ext/vertica/model/VerticaTableColumn.java
...g/jkiss/dbeaver/ext/vertica/model/VerticaTableColumn.java
+33
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBConstants.java
...beaver.model/src/org/jkiss/dbeaver/model/DBConstants.java
+3
-0
未找到文件。
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreTableColumnManager.java
浏览文件 @
a31179de
...
...
@@ -209,14 +209,14 @@ public class PostgreTableColumnManager extends SQLTableColumnManager<PostgreTabl
if
(
column
.
getDataType
()
!=
null
)
{
typeClause
+=
" USING "
+
DBUtils
.
getQuotedIdentifier
(
column
)
+
"::"
+
column
.
getDataType
().
getName
();
}
if
(
command
.
getProperty
(
"dataType"
)
!=
null
||
command
.
getProperty
(
"maxLength"
)
!=
null
||
command
.
getProperty
(
"precision"
)
!=
null
||
command
.
getProperty
(
"scale"
)
!=
null
)
{
if
(
command
.
getProperty
(
DBConstants
.
PROP_ID_DATA_TYPE
)
!=
null
||
command
.
getProperty
(
"maxLength"
)
!=
null
||
command
.
getProperty
(
"precision"
)
!=
null
||
command
.
getProperty
(
"scale"
)
!=
null
)
{
actionList
.
add
(
new
SQLDatabasePersistAction
(
"Set column type"
,
prefix
+
"TYPE "
+
typeClause
));
}
if
(
command
.
getProperty
(
"required"
)
!=
null
)
{
if
(
command
.
getProperty
(
DBConstants
.
PROP_ID_REQUIRED
)
!=
null
)
{
actionList
.
add
(
new
SQLDatabasePersistAction
(
"Set column nullability"
,
prefix
+
(
column
.
isRequired
()
?
"SET"
:
"DROP"
)
+
" NOT NULL"
));
}
if
(
command
.
getProperty
(
"defaultValue"
)
!=
null
)
{
if
(
command
.
getProperty
(
DBConstants
.
PROP_ID_DEFAULT_VALUE
)
!=
null
)
{
if
(
CommonUtils
.
isEmpty
(
column
.
getDefaultValue
()))
{
actionList
.
add
(
new
SQLDatabasePersistAction
(
"Drop column default"
,
prefix
+
"DROP DEFAULT"
));
}
else
{
...
...
plugins/org.jkiss.dbeaver.ext.vertica/plugin.xml
浏览文件 @
a31179de
...
...
@@ -186,4 +186,11 @@
</datasource>
</extension>
<extension
point=
"org.jkiss.dbeaver.databaseEditor"
>
<manager
class=
"org.jkiss.dbeaver.ext.vertica.edit.VerticaTableColumnManager"
objectType=
"org.jkiss.dbeaver.ext.vertica.model.VerticaTableColumn"
/>
</extension>
</plugin>
plugins/org.jkiss.dbeaver.ext.vertica/src/org/jkiss/dbeaver/ext/vertica/edit/VerticaTableColumnManager.java
0 → 100644
浏览文件 @
a31179de
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ext.vertica.edit
;
import
org.jkiss.dbeaver.ext.generic.edit.GenericTableColumnManager
;
import
org.jkiss.dbeaver.ext.generic.model.GenericTable
;
import
org.jkiss.dbeaver.ext.generic.model.GenericTableColumn
;
import
org.jkiss.dbeaver.model.DBConstants
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.impl.edit.DBECommandAbstract
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.List
;
import
java.util.Map
;
/**
* Vertica table column manager
*/
public
class
VerticaTableColumnManager
extends
GenericTableColumnManager
{
protected
final
ColumnModifier
<
GenericTableColumn
>
VerticaDataTypeModifier
=
(
column
,
sql
,
command
)
->
{
sql
.
append
(
" SET DATA TYPE "
);
DataTypeModifier
.
appendModifier
(
column
,
sql
,
command
);
};
protected
final
ColumnModifier
<
GenericTableColumn
>
VerticaDefaultModifier
=
(
column
,
sql
,
command
)
->
{
if
(
CommonUtils
.
isEmpty
(
command
.
getObject
().
getDefaultValue
()))
{
sql
.
append
(
" DROP DEFAULT"
);
}
else
{
sql
.
append
(
" SET DEFAULT "
);
DefaultModifier
.
appendModifier
(
column
,
sql
,
command
);
}
};
protected
final
ColumnModifier
<
GenericTableColumn
>
VerticaNotNullModifier
=
(
column
,
sql
,
command
)
->
{
if
(
command
.
getObject
().
isRequired
())
{
sql
.
append
(
" SET NOT NULL"
);
}
else
{
sql
.
append
(
" DROP NOT NULL"
);
}
};
@Override
public
StringBuilder
getNestedDeclaration
(
GenericTable
owner
,
DBECommandAbstract
<
GenericTableColumn
>
command
,
Map
<
String
,
Object
>
options
)
{
StringBuilder
decl
=
super
.
getNestedDeclaration
(
owner
,
command
,
options
);
final
GenericTableColumn
column
=
command
.
getObject
();
if
(
column
.
isAutoIncrement
())
{
final
String
autoIncrementClause
=
column
.
getDataSource
().
getMetaModel
().
getAutoIncrementClause
(
column
);
if
(
autoIncrementClause
!=
null
&&
!
autoIncrementClause
.
isEmpty
())
{
decl
.
append
(
" "
).
append
(
autoIncrementClause
);
//$NON-NLS-1$
}
}
return
decl
;
}
@Override
protected
ColumnModifier
[]
getSupportedModifiers
(
GenericTableColumn
column
,
Map
<
String
,
Object
>
options
)
{
// According to SQL92 DEFAULT comes before constraints
return
new
ColumnModifier
[]
{
VerticaDataTypeModifier
,
VerticaDefaultModifier
,
VerticaNotNullModifier
};
}
/**
* Copy-pasted from PostgreSQL implementation.
* TODO: Vertica is originally based on PG. <aybe we should refactor this stuff somehow.
*/
@Override
protected
void
addObjectModifyActions
(
List
<
DBEPersistAction
>
actionList
,
ObjectChangeCommand
command
,
Map
<
String
,
Object
>
options
)
{
final
GenericTableColumn
column
=
command
.
getObject
();
String
prefix
=
"ALTER TABLE "
+
DBUtils
.
getObjectFullName
(
column
.
getTable
(),
DBPEvaluationContext
.
DDL
)
+
" ALTER COLUMN "
+
DBUtils
.
getQuotedIdentifier
(
column
)
+
" "
;
String
typeClause
=
column
.
getFullTypeName
();
if
(
command
.
getProperty
(
DBConstants
.
PROP_ID_DATA_TYPE
)
!=
null
||
command
.
getProperty
(
"maxLength"
)
!=
null
||
command
.
getProperty
(
"precision"
)
!=
null
||
command
.
getProperty
(
"scale"
)
!=
null
)
{
actionList
.
add
(
new
SQLDatabasePersistAction
(
"Set column type"
,
prefix
+
"TYPE "
+
typeClause
));
}
if
(
command
.
getProperty
(
DBConstants
.
PROP_ID_REQUIRED
)
!=
null
)
{
actionList
.
add
(
new
SQLDatabasePersistAction
(
"Set column nullability"
,
prefix
+
(
column
.
isRequired
()
?
"SET"
:
"DROP"
)
+
" NOT NULL"
));
}
if
(
command
.
getProperty
(
DBConstants
.
PROP_ID_DEFAULT_VALUE
)
!=
null
)
{
if
(
CommonUtils
.
isEmpty
(
column
.
getDefaultValue
()))
{
actionList
.
add
(
new
SQLDatabasePersistAction
(
"Drop column default"
,
prefix
+
"DROP DEFAULT"
));
}
else
{
actionList
.
add
(
new
SQLDatabasePersistAction
(
"Set column default"
,
prefix
+
"SET DEFAULT "
+
column
.
getDefaultValue
()));
}
}
if
(
command
.
getProperty
(
DBConstants
.
PROP_ID_DESCRIPTION
)
!=
null
)
{
actionList
.
add
(
new
SQLDatabasePersistAction
(
"Set column comment"
,
"COMMENT ON COLUMN "
+
DBUtils
.
getObjectFullName
(
column
.
getTable
(),
DBPEvaluationContext
.
DDL
)
+
"."
+
DBUtils
.
getQuotedIdentifier
(
column
)
+
" IS "
+
SQLUtils
.
quoteString
(
column
,
CommonUtils
.
notEmpty
(
column
.
getDescription
()))));
}
}
}
plugins/org.jkiss.dbeaver.ext.vertica/src/org/jkiss/dbeaver/ext/vertica/model/VerticaTableColumn.java
浏览文件 @
a31179de
...
...
@@ -16,12 +16,10 @@
*/
package
org.jkiss.dbeaver.ext.vertica.model
;
import
org.jkiss.
dbeaver.DBException
;
import
org.jkiss.
code.Nullable
;
import
org.jkiss.dbeaver.ext.generic.model.GenericTable
;
import
org.jkiss.dbeaver.ext.generic.model.GenericTableColumn
;
import
org.jkiss.dbeaver.ext.vertica.VerticaUtils
;
import
org.jkiss.dbeaver.model.meta.Property
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
/**
* VerticaTableColumn
...
...
@@ -37,4 +35,36 @@ public class VerticaTableColumn extends GenericTableColumn
super
(
table
,
columnName
,
typeName
,
valueType
,
sourceType
,
ordinalPosition
,
columnSize
,
charLength
,
scale
,
precision
,
radix
,
notNull
,
remarks
,
defaultValue
,
autoIncrement
,
autoGenerated
);
}
@Property
(
viewable
=
true
,
editable
=
true
,
updatable
=
true
,
order
=
20
,
listProvider
=
ColumnTypeNameListProvider
.
class
)
@Override
public
String
getTypeName
()
{
return
super
.
getTypeName
();
}
@Property
(
viewable
=
true
,
editable
=
true
,
updatable
=
true
,
order
=
40
)
@Override
public
long
getMaxLength
()
{
return
super
.
getMaxLength
();
}
@Property
(
viewable
=
true
,
editable
=
true
,
updatable
=
true
,
order
=
50
)
@Override
public
boolean
isRequired
()
{
return
super
.
isRequired
();
}
@Property
(
viewable
=
true
,
editable
=
true
,
updatable
=
true
,
order
=
70
)
@Override
public
String
getDefaultValue
()
{
return
super
.
getDefaultValue
();
}
@Nullable
@Override
@Property
(
viewable
=
true
,
editable
=
true
,
updatable
=
true
,
order
=
100
)
public
String
getDescription
()
{
return
super
.
getDescription
();
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBConstants.java
浏览文件 @
a31179de
...
...
@@ -39,6 +39,9 @@ public class DBConstants {
public
static
final
String
PROP_ID_NAME
=
"name"
;
//NON-NLS-1
public
static
final
String
PROP_ID_DESCRIPTION
=
"description"
;
//NON-NLS-1
public
static
final
String
PROP_ID_DATA_TYPE
=
"dataType"
;
//NON-NLS-1
public
static
final
String
PROP_ID_REQUIRED
=
"required"
;
//NON-NLS-1
public
static
final
String
PROP_ID_DEFAULT_VALUE
=
"defaultValue"
;
//NON-NLS-1
public
static
final
String
PROP_ID_TYPE_NAME
=
"typeName"
;
//NON-NLS-1
public
static
final
String
PROP_ID_MAX_LENGTH
=
"maxLength"
;
//NON-NLS-1
public
static
final
String
PROP_ID_NOT_NULL
=
"notNull"
;
//NON-NLS-1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录