Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
e8d48dff
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,发现更多精彩内容 >>
提交
e8d48dff
编写于
11月 06, 2020
作者:
L
LonwoLonwo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#10261 table DDL refactoring
Former-commit-id:
59647ae8
上级
47cf8875
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
12 deletion
+17
-12
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/tools/ExasolUtils.java
...l/src/org/jkiss/dbeaver/ext/exasol/tools/ExasolUtils.java
+17
-12
未找到文件。
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/tools/ExasolUtils.java
浏览文件 @
e8d48dff
...
...
@@ -31,6 +31,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttributeRef
;
import
org.jkiss.utils.CommonUtils
;
import
java.math.BigDecimal
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
...
...
@@ -91,24 +92,28 @@ public class ExasolUtils {
// double quotation mark for column as the name could be a
// reserved word
columnString
.
append
(
"\n\t\t\""
).
append
(
rs
.
getString
(
"COLUMN_NAME"
)).
append
(
"\" "
).
append
(
rs
.
getString
(
"COLUMN_TYPE"
)).
append
(
" "
);
columnString
.
append
(
"\n\t\t"
).
append
(
DBUtils
.
getQuotedIdentifier
(
dataSource
,
CommonUtils
.
notEmpty
(
rs
.
getString
(
"COLUMN_NAME"
)))).
append
(
" "
).
append
(
rs
.
getString
(
"COLUMN_TYPE"
));
// has default value?
if
(
rs
.
getString
(
"COLUMN_DEFAULT"
)
!=
null
)
columnString
.
append
(
"DEFAULT "
).
append
(
rs
.
getString
(
"COLUMN_DEFAULT"
)).
append
(
" "
);
String
columnDefault
=
rs
.
getString
(
"COLUMN_DEFAULT"
);
if
(
columnDefault
!=
null
)
columnString
.
append
(
" DEFAULT "
).
append
(
columnDefault
);
// has identity
if
(
rs
.
getBigDecimal
(
"COLUMN_IDENTITY"
)
!=
null
)
columnString
.
append
(
"IDENTITY "
).
append
(
rs
.
getBigDecimal
(
"COLUMN_IDENTITY"
).
toString
()).
append
(
" "
);
BigDecimal
bigDecimal
=
rs
.
getBigDecimal
(
"COLUMN_IDENTITY"
);
if
(
bigDecimal
!=
null
)
columnString
.
append
(
" IDENTITY "
).
append
(
bigDecimal
.
toString
());
// has identity
if
(!
rs
.
getBoolean
(
"COLUMN_IS_NULLABLE"
))
columnString
.
append
(
"
NOT NULL
"
);
columnString
.
append
(
"
NOT NULL
"
);
// comment
if
(
rs
.
getString
(
"COLUMN_COMMENT"
)
!=
null
)
String
columnComment
=
rs
.
getString
(
"COLUMN_COMMENT"
);
if
(
columnComment
!=
null
)
// replace ' to double ' -> escape for SQL
columnString
.
append
(
"
COMMENT IS '"
).
append
(
rs
.
getString
(
"COLUMN_COMMENT"
)
.
replaceAll
(
"'"
,
"''"
)).
append
(
"'"
);
columnString
.
append
(
"
COMMENT IS '"
).
append
(
columnComment
.
replaceAll
(
"'"
,
"''"
)).
append
(
"'"
);
// if distkey add column to distkey
if
(
rs
.
getBoolean
(
"COLUMN_IS_DISTRIBUTION_KEY"
))
...
...
@@ -173,7 +178,7 @@ public class ExasolUtils {
return
String
.
format
(
"ALTER TABLE %s PARTITION BY %s;"
,
"ALTER TABLE %s PARTITION BY %s;
\n
"
,
DBUtils
.
getObjectFullName
(
table
,
DBPEvaluationContext
.
DDL
),
colList
);
...
...
@@ -191,10 +196,10 @@ public class ExasolUtils {
for
(
DBSEntityAttributeRef
c
:
fk
.
getReferencedConstraint
().
getAttributeReferences
(
monitor
))
{
refColumns
.
add
(
DBUtils
.
getQuotedIdentifier
(
c
.
getAttribute
()));
}
String
fk_enabled
=
" DISABLE
"
;
String
fk_enabled
=
" DISABLE"
;
if
(
fk
.
getEnabled
())
fk_enabled
=
" ENABLE
"
;
fk_enabled
=
" ENABLE"
;
return
"ALTER TABLE "
+
DBUtils
.
getObjectFullName
(
exasolTable
,
DBPEvaluationContext
.
DDL
)
+
" ADD CONSTRAINT "
+
DBUtils
.
getQuotedIdentifier
(
fk
)
+
...
...
@@ -210,7 +215,7 @@ public class ExasolUtils {
for
(
DBSEntityAttributeRef
c
:
pk
.
getAttributeReferences
(
monitor
))
{
columns
.
add
(
"\""
+
c
.
getAttribute
().
getName
()
+
"\""
);
}
return
"ALTER TABLE "
+
DBUtils
.
getObjectFullName
(
exasolTable
,
DBPEvaluationContext
.
DDL
)
+
" ADD CONSTRAINT "
+
DBUtils
.
getQuotedIdentifier
(
pk
)
+
" PRIMARY KEY ("
+
CommonUtils
.
joinStrings
(
","
,
columns
)
+
") "
+
(
pk
.
getEnabled
()
?
"
ENABLE "
:
" DISABLE
"
);
return
"ALTER TABLE "
+
DBUtils
.
getObjectFullName
(
exasolTable
,
DBPEvaluationContext
.
DDL
)
+
" ADD CONSTRAINT "
+
DBUtils
.
getQuotedIdentifier
(
pk
)
+
" PRIMARY KEY ("
+
CommonUtils
.
joinStrings
(
","
,
columns
)
+
") "
+
(
pk
.
getEnabled
()
?
"
ENABLE"
:
"DISABLE
"
);
}
public
static
String
getConnectionDdl
(
ExasolConnection
con
,
DBRProgressMonitor
monitor
)
throws
DBException
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录