Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
94e3e885
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,发现更多精彩内容 >>
提交
94e3e885
编写于
7月 09, 2017
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Column modifiers gen fix (dialect-specific)
上级
72acd155
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
73 addition
and
59 deletion
+73
-59
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/database/DatabaseMappingAttribute.java
...ver/tools/transfer/database/DatabaseMappingAttribute.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
...ss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
+3
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/BasicSQLDialect.java
...src/org/jkiss/dbeaver/model/impl/sql/BasicSQLDialect.java
+58
-7
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/edit/struct/SQLTableColumnManager.java
...ver/model/impl/sql/edit/struct/SQLTableColumnManager.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/SQLDialect.java
...ver.model/src/org/jkiss/dbeaver/model/sql/SQLDialect.java
+5
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/SQLUtils.java
...eaver.model/src/org/jkiss/dbeaver/model/sql/SQLUtils.java
+5
-49
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/transfer/database/DatabaseMappingAttribute.java
浏览文件 @
94e3e885
...
...
@@ -218,7 +218,7 @@ class DatabaseMappingAttribute implements DatabaseMappingObject {
}
}
String
modifiers
=
SQLUtils
.
getColumnTypeModifiers
(
source
,
typeName
,
dataKind
);
String
modifiers
=
SQLUtils
.
getColumnTypeModifiers
(
parent
.
getSettings
().
getTargetDataSource
(
this
),
source
,
typeName
,
dataKind
);
if
(
modifiers
!=
null
)
{
typeName
+=
modifiers
;
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
浏览文件 @
94e3e885
...
...
@@ -1149,8 +1149,10 @@ public final class DBUtils {
@NotNull
public
static
String
getFullTypeName
(
@NotNull
DBSTypedObject
typedObject
)
{
DBSObject
structObject
=
getFromObject
(
typedObject
);
DBPDataSource
dataSource
=
structObject
==
null
?
null
:
structObject
.
getDataSource
();
String
typeName
=
typedObject
.
getTypeName
();
String
typeModifiers
=
SQLUtils
.
getColumnTypeModifiers
(
typedObject
,
typeName
,
typedObject
.
getDataKind
());
String
typeModifiers
=
SQLUtils
.
getColumnTypeModifiers
(
dataSource
,
typedObject
,
typeName
,
typedObject
.
getDataKind
());
return
typeModifiers
==
null
?
typeName
:
(
typeName
+
CommonUtils
.
notEmpty
(
typeModifiers
));
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/BasicSQLDialect.java
浏览文件 @
94e3e885
...
...
@@ -18,18 +18,16 @@ package org.jkiss.dbeaver.model.impl.sql;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPIdentifierCase
;
import
org.jkiss.dbeaver.model.DBPKeywordType
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.data.DBDBinaryFormatter
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterHexNative
;
import
org.jkiss.dbeaver.model.sql.SQLConstants
;
import
org.jkiss.dbeaver.model.sql.SQLDialect
;
import
org.jkiss.dbeaver.model.sql.SQLStateType
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.sql.*
;
import
org.jkiss.dbeaver.model.sql.parser.SQLSemanticProcessor
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.dbeaver.model.struct.DBSDataType
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.Pair
;
...
...
@@ -464,4 +462,57 @@ public class BasicSQLDialect implements SQLDialect {
}
}
@Override
public
String
getColumnTypeModifiers
(
@NotNull
DBSTypedObject
column
,
@NotNull
String
typeName
,
@NotNull
DBPDataKind
dataKind
)
{
typeName
=
CommonUtils
.
notEmpty
(
typeName
).
toUpperCase
(
Locale
.
ENGLISH
);
if
(
column
instanceof
DBSObject
)
{
// If type is UDT (i.e. we can find it in type list) and type precision == column precision
// then do not use explicit precision in column definition
final
DBSDataType
dataType
=
DBUtils
.
getLocalDataType
(((
DBSObject
)
column
).
getDataSource
(),
column
.
getTypeName
());
if
(
dataType
!=
null
&&
dataType
.
getScale
()
==
column
.
getScale
()
&&
((
dataType
.
getPrecision
()
>
0
&&
dataType
.
getPrecision
()
==
column
.
getPrecision
())
||
(
dataType
.
getMaxLength
()
>
0
&&
dataType
.
getMaxLength
()
==
column
.
getMaxLength
())))
{
return
null
;
}
}
if
(
dataKind
==
DBPDataKind
.
STRING
)
{
if
(
typeName
.
indexOf
(
'('
)
==
-
1
)
{
final
long
maxLength
=
column
.
getMaxLength
();
if
(
maxLength
>
0
)
{
return
"("
+
maxLength
+
")"
;
}
}
}
else
if
(
dataKind
==
DBPDataKind
.
CONTENT
&&
!
typeName
.
contains
(
"LOB"
))
{
final
long
maxLength
=
column
.
getMaxLength
();
if
(
maxLength
>
0
)
{
return
"("
+
maxLength
+
')'
;
}
}
else
if
(
dataKind
==
DBPDataKind
.
NUMERIC
)
{
if
(
typeName
.
equals
(
"DECIMAL"
)
||
typeName
.
equals
(
"NUMERIC"
)
||
typeName
.
equals
(
"NUMBER"
))
{
int
scale
=
column
.
getScale
();
int
precision
=
column
.
getPrecision
();
if
(
precision
==
0
)
{
precision
=
(
int
)
column
.
getMaxLength
();
if
(
precision
>
0
)
{
// FIXME: max length is actually length in character.
// FIXME: On Oracle it returns bigger values than maximum (#1767)
// FIXME: in other DBs it equals to precision in most cases
//precision--; // One character for sign?
}
}
if
(
scale
>=
0
&&
precision
>=
0
&&
!(
scale
==
0
&&
precision
==
0
))
{
return
"("
+
precision
+
','
+
scale
+
')'
;
}
}
else
if
(
typeName
.
equals
(
"BIT"
))
{
// Bit string?
int
precision
=
column
.
getPrecision
();
if
(
precision
>
1
)
{
return
"("
+
precision
+
')'
;
}
}
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/edit/struct/SQLTableColumnManager.java
浏览文件 @
94e3e885
...
...
@@ -60,7 +60,7 @@ public abstract class SQLTableColumnManager<OBJECT_TYPE extends JDBCTableColumn<
}
else
{
dataKind
=
dataType
.
getDataKind
();
}
String
modifiers
=
SQLUtils
.
getColumnTypeModifiers
(
column
,
typeName
,
dataKind
);
String
modifiers
=
SQLUtils
.
getColumnTypeModifiers
(
column
.
getDataSource
(),
column
,
typeName
,
dataKind
);
if
(
modifiers
!=
null
)
{
sql
.
append
(
modifiers
);
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/SQLDialect.java
浏览文件 @
94e3e885
...
...
@@ -18,12 +18,14 @@ package org.jkiss.dbeaver.model.sql;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBPDataKind
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPIdentifierCase
;
import
org.jkiss.dbeaver.model.DBPKeywordType
;
import
org.jkiss.dbeaver.model.data.DBDBinaryFormatter
;
import
org.jkiss.dbeaver.model.data.DBDDataFilter
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.utils.Pair
;
import
java.util.List
;
...
...
@@ -289,4 +291,7 @@ public interface SQLDialect {
boolean
isTransactionModifyingQuery
(
String
queryString
);
@Nullable
String
getColumnTypeModifiers
(
@NotNull
DBSTypedObject
column
,
@NotNull
String
typeName
,
@NotNull
DBPDataKind
dataKind
);
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/SQLUtils.java
浏览文件 @
94e3e885
...
...
@@ -561,59 +561,15 @@ public final class SQLUtils {
}
}
public
static
String
getColumnTypeModifiers
(
DBSTypedObject
column
,
@NotNull
String
typeName
,
@NotNull
DBPDataKind
dataKind
)
{
public
static
String
getColumnTypeModifiers
(
@Nullable
DBPDataSource
dataSource
,
DBSTypedObject
column
,
@NotNull
String
typeName
,
@NotNull
DBPDataKind
dataKind
)
{
if
(
column
==
null
)
{
return
null
;
}
typeName
=
CommonUtils
.
notEmpty
(
typeName
).
toUpperCase
(
Locale
.
ENGLISH
);
if
(
column
instanceof
DBSObject
)
{
// If type is UDT (i.e. we can find it in type list) and type precision == column precision
// then do not use explicit precision in column definition
final
DBSDataType
dataType
=
DBUtils
.
getLocalDataType
(((
DBSObject
)
column
).
getDataSource
(),
column
.
getTypeName
());
if
(
dataType
!=
null
&&
dataType
.
getScale
()
==
column
.
getScale
()
&&
((
dataType
.
getPrecision
()
>
0
&&
dataType
.
getPrecision
()
==
column
.
getPrecision
())
||
(
dataType
.
getMaxLength
()
>
0
&&
dataType
.
getMaxLength
()
==
column
.
getMaxLength
())))
{
return
null
;
}
}
if
(
dataKind
==
DBPDataKind
.
STRING
)
{
if
(
typeName
.
indexOf
(
'('
)
==
-
1
)
{
final
long
maxLength
=
column
.
getMaxLength
();
if
(
maxLength
>
0
)
{
return
"("
+
maxLength
+
")"
;
}
}
}
else
if
(
dataKind
==
DBPDataKind
.
CONTENT
&&
!
typeName
.
contains
(
"LOB"
))
{
final
long
maxLength
=
column
.
getMaxLength
();
if
(
maxLength
>
0
)
{
return
"("
+
maxLength
+
')'
;
}
}
else
if
(
dataKind
==
DBPDataKind
.
NUMERIC
)
{
if
(
typeName
.
equals
(
"DECIMAL"
)
||
typeName
.
equals
(
"NUMERIC"
)
||
typeName
.
equals
(
"NUMBER"
))
{
int
scale
=
column
.
getScale
();
int
precision
=
column
.
getPrecision
();
if
(
precision
==
0
)
{
precision
=
(
int
)
column
.
getMaxLength
();
if
(
precision
>
0
)
{
// FIXME: max length is actually length in character.
// FIXME: On Oracle it returns bigger values than maximum (#1767)
// FIXME: in other DBs it equals to precision in most cases
//precision--; // One character for sign?
}
}
if
(
scale
>=
0
&&
precision
>=
0
&&
!(
scale
==
0
&&
precision
==
0
))
{
return
"("
+
precision
+
','
+
scale
+
')'
;
}
}
else
if
(
typeName
.
equals
(
"BIT"
))
{
// Bit string?
int
precision
=
column
.
getPrecision
();
if
(
precision
>
1
)
{
return
"("
+
precision
+
')'
;
}
}
if
(!(
dataSource
instanceof
SQLDataSource
))
{
return
null
;
}
return
null
;
SQLDialect
dialect
=
((
SQLDataSource
)
dataSource
).
getSQLDialect
();
return
dialect
.
getColumnTypeModifiers
(
column
,
typeName
,
dataKind
);
}
public
static
boolean
isExecQuery
(
@NotNull
SQLDialect
dialect
,
String
query
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录