Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
aa9087a0
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,发现更多精彩内容 >>
提交
aa9087a0
编写于
9月 26, 2020
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#9293 Export as SQL: support native fetch in native date/time format
上级
f5ec3da3
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
49 addition
and
16 deletion
+49
-16
plugins/org.jkiss.dbeaver.data.transfer/OSGI-INF/l10n/bundle.properties
...iss.dbeaver.data.transfer/OSGI-INF/l10n/bundle.properties
+2
-0
plugins/org.jkiss.dbeaver.data.transfer/plugin.xml
plugins/org.jkiss.dbeaver.data.transfer/plugin.xml
+1
-1
plugins/org.jkiss.dbeaver.data.transfer/src/org/jkiss/dbeaver/tools/transfer/stream/exporter/DataExporterSQL.java
...eaver/tools/transfer/stream/exporter/DataExporterSQL.java
+17
-15
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/data/OracleTemporalAccessorValueHandler.java
...r/ext/oracle/data/OracleTemporalAccessorValueHandler.java
+15
-0
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/data/OracleTimestampValueHandler.java
.../dbeaver/ext/oracle/data/OracleTimestampValueHandler.java
+14
-0
未找到文件。
plugins/org.jkiss.dbeaver.data.transfer/OSGI-INF/l10n/bundle.properties
浏览文件 @
aa9087a0
...
...
@@ -74,6 +74,8 @@ dataTransfer.processor.sql.property.omitSchema.name=Omit schema name
dataTransfer.processor.sql.property.omitSchema.description
=
Omit schema/catalog name in INSERT statements
dataTransfer.processor.sql.property.rowsInStatement.name
=
Data rows per statement
dataTransfer.processor.sql.property.rowsInStatement.description
=
Number of data rows per single insert statement
dataTransfer.processor.sql.property.nativeFormat.name
=
Native date/time format
dataTransfer.processor.sql.property.nativeFormat.description
=
Use native date/time format in INSERT statements
dataTransfer.processor.xml.name
=
XML
dataTransfer.processor.xml.description
=
Export to XML file(s)
dataTransfer.processor.xml.propertyGroup.general.label
=
General
...
...
plugins/org.jkiss.dbeaver.data.transfer/plugin.xml
浏览文件 @
aa9087a0
...
...
@@ -164,7 +164,7 @@
<propertyGroup
label=
"%dataTransfer.processor.sql.propertyGroup.general.label"
>
<property
id=
"includeAutoGenerated"
label=
"%dataTransfer.processor.sql.property.includeAutoGenerated.label"
description=
"%dataTransfer.processor.sql.property.includeAutoGenerated.description"
type=
"boolean"
defaultValue=
"false"
/>
<property
id=
"extension"
label=
"%dataTransfer.processor.sql.property.extension.label"
type=
"string"
defaultValue=
"sql"
/>
<property
id=
"
format"
label=
"%dataTransfer.processor.xml.property.format.label"
type=
"string"
defaultValue=
"native"
validValues=
"ui,edit,native"
/>
<property
id=
"
nativeFormat"
label=
"%dataTransfer.processor.sql.property.nativeFormat.name"
type=
"boolean"
description=
"%dataTransfer.processor.sql.property.nativeFormat.description"
defaultValue=
"true"
/>
<property
id=
"omitSchema"
label=
"%dataTransfer.processor.sql.property.omitSchema.name"
type=
"boolean"
description=
"%dataTransfer.processor.sql.property.omitSchema.description"
required=
"false"
defaultValue=
"false"
/>
<property
id=
"rowsInStatement"
label=
"%dataTransfer.processor.sql.property.rowsInStatement.name"
type=
"integer"
description=
"%dataTransfer.processor.sql.property.rowsInStatement.description"
defaultValue=
"10"
required=
"true"
/>
</propertyGroup>
...
...
plugins/org.jkiss.dbeaver.data.transfer/src/org/jkiss/dbeaver/tools/transfer/stream/exporter/DataExporterSQL.java
浏览文件 @
aa9087a0
...
...
@@ -48,12 +48,14 @@ public class DataExporterSQL extends StreamExporterAbstract {
private
static
final
String
PROP_INCLUDE_AUTO_GENERATED
=
"includeAutoGenerated"
;
private
static
final
String
PROP_OMIT_SCHEMA
=
"omitSchema"
;
private
static
final
String
PROP_ROWS_IN_STATEMENT
=
"rowsInStatement"
;
private
static
final
String
PROP_DATA_FORMAT
=
"nativeFormat"
;
private
static
final
char
STRING_QUOTE
=
'\''
;
private
boolean
includeAutoGenerated
;
private
String
rowDelimiter
;
private
boolean
omitSchema
;
private
int
rowsInStatement
;
private
boolean
useNativeDataFormat
=
true
;
private
String
tableName
;
private
DBDAttributeBinding
[]
columns
;
...
...
@@ -67,8 +69,7 @@ public class DataExporterSQL extends StreamExporterAbstract {
}
@Override
public
void
init
(
IStreamDataExporterSite
site
)
throws
DBException
{
public
void
init
(
IStreamDataExporterSite
site
)
throws
DBException
{
super
.
init
(
site
);
if
(
site
.
getProperties
().
containsKey
(
PROP_INCLUDE_AUTO_GENERATED
))
{
...
...
@@ -82,19 +83,23 @@ public class DataExporterSQL extends StreamExporterAbstract {
}
catch
(
NumberFormatException
e
)
{
rowsInStatement
=
10
;
}
useNativeDataFormat
=
CommonUtils
.
toBoolean
(
site
.
getProperties
().
get
(
PROP_DATA_FORMAT
));
rowDelimiter
=
GeneralUtils
.
getDefaultLineSeparator
();
dialect
=
SQLUtils
.
getDialectFromObject
(
site
.
getSource
());
}
@Override
public
void
dispose
()
{
public
void
dispose
()
{
super
.
dispose
();
}
@Override
public
void
exportHeader
(
DBCSession
session
)
throws
DBException
,
IOException
{
public
void
exportHeader
(
DBCSession
session
)
throws
DBException
,
IOException
{
if
(
useNativeDataFormat
)
{
if
(
session
instanceof
DBDFormatSettingsExt
)
{
((
DBDFormatSettingsExt
)
session
).
setUseNativeDateTimeFormat
(
true
);
}
}
columns
=
getSite
().
getAttributes
();
DBPNamedObject
source
=
getSite
().
getSource
();
tableName
=
DTUtils
.
getTableName
(
session
.
getDataSource
(),
source
,
omitSchema
);
...
...
@@ -103,8 +108,7 @@ public class DataExporterSQL extends StreamExporterAbstract {
}
@Override
public
void
exportRow
(
DBCSession
session
,
DBCResultSet
resultSet
,
Object
[]
row
)
throws
DBException
,
IOException
{
public
void
exportRow
(
DBCSession
session
,
DBCResultSet
resultSet
,
Object
[]
row
)
throws
DBException
,
IOException
{
PrintWriter
out
=
getWriter
();
SQLDialect
.
MultiValueInsertMode
insertMode
=
rowsInStatement
==
1
?
SQLDialect
.
MultiValueInsertMode
.
NOT_SUPPORTED
:
getMultiValueInsertMode
();
if
(
insertMode
==
SQLDialect
.
MultiValueInsertMode
.
NOT_SUPPORTED
)
{
...
...
@@ -168,7 +172,7 @@ public class DataExporterSQL extends StreamExporterAbstract {
// just skip it
out
.
write
(
SQLConstants
.
NULL_VALUE
);
}
else
if
(
row
[
i
]
instanceof
DBDContent
)
{
DBDContent
content
=
(
DBDContent
)
row
[
i
];
DBDContent
content
=
(
DBDContent
)
row
[
i
];
try
{
if
(
column
.
getValueHandler
()
instanceof
DBDContentValueHandler
)
{
((
DBDContentValueHandler
)
column
.
getValueHandler
()).
writeStreamValue
(
session
.
getProgressMonitor
(),
session
.
getDataSource
(),
column
,
content
,
out
);
...
...
@@ -193,7 +197,7 @@ public class DataExporterSQL extends StreamExporterAbstract {
}
}
else
if
(
value
instanceof
File
)
{
out
.
write
(
"@"
);
out
.
write
(((
File
)
value
).
getAbsolutePath
());
out
.
write
(((
File
)
value
).
getAbsolutePath
());
}
else
{
out
.
write
(
SQLUtils
.
convertValueToSQL
(
session
.
getDataSource
(),
column
,
row
[
i
]));
}
...
...
@@ -225,8 +229,7 @@ public class DataExporterSQL extends StreamExporterAbstract {
}
}
private
void
writeStringValue
(
String
value
)
{
private
void
writeStringValue
(
String
value
)
{
PrintWriter
out
=
getWriter
();
out
.
write
(
STRING_QUOTE
);
if
(
dialect
!=
null
)
{
...
...
@@ -237,14 +240,13 @@ public class DataExporterSQL extends StreamExporterAbstract {
out
.
write
(
STRING_QUOTE
);
}
private
void
writeStringValue
(
Reader
reader
)
throws
IOException
{
private
void
writeStringValue
(
Reader
reader
)
throws
IOException
{
try
{
PrintWriter
out
=
getWriter
();
out
.
write
(
STRING_QUOTE
);
// Copy reader
char
buffer
[]
=
new
char
[
2000
];
for
(;
;
)
{
for
(;
;
)
{
int
count
=
reader
.
read
(
buffer
);
if
(
count
<=
0
)
{
break
;
...
...
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/data/OracleTemporalAccessorValueHandler.java
浏览文件 @
aa9087a0
...
...
@@ -16,9 +16,11 @@
*/
package
org.jkiss.dbeaver.ext.oracle.data
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.ext.oracle.model.OracleConstants
;
import
org.jkiss.dbeaver.model.data.DBDDataFormatter
;
import
org.jkiss.dbeaver.model.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.model.data.DBDFormatSettings
;
import
org.jkiss.dbeaver.model.impl.jdbc.data.handlers.JDBCTemporalAccessorValueHandler
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
...
...
@@ -40,6 +42,19 @@ public class OracleTemporalAccessorValueHandler extends JDBCTemporalAccessorValu
super
(
formatSettings
);
}
@NotNull
@Override
public
String
getValueDisplayString
(
@NotNull
DBSTypedObject
column
,
Object
value
,
@NotNull
DBDDisplayFormat
format
)
{
if
(
format
==
DBDDisplayFormat
.
NATIVE
&&
value
instanceof
String
)
{
if
(!((
String
)
value
).
startsWith
(
"TIMESTAMP"
))
{
return
"TIMESTAMP'"
+
value
+
"'"
;
}
else
{
return
(
String
)
value
;
}
}
return
super
.
getValueDisplayString
(
column
,
value
,
format
);
}
@Nullable
@Override
public
DateTimeFormatter
getNativeValueFormat
(
DBSTypedObject
type
)
{
...
...
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/data/OracleTimestampValueHandler.java
浏览文件 @
aa9087a0
...
...
@@ -20,6 +20,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.ext.oracle.model.OracleConstants
;
import
org.jkiss.dbeaver.model.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.model.data.DBDFormatSettings
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCSession
;
...
...
@@ -65,6 +66,19 @@ public class OracleTimestampValueHandler extends JDBCDateTimeValueHandler {
return
super
.
getValueFromObject
(
session
,
type
,
object
,
copy
,
validateValue
);
}
@NotNull
@Override
public
String
getValueDisplayString
(
@NotNull
DBSTypedObject
column
,
Object
value
,
@NotNull
DBDDisplayFormat
format
)
{
if
(
format
==
DBDDisplayFormat
.
NATIVE
&&
value
instanceof
String
)
{
if
(!((
String
)
value
).
startsWith
(
"TIMESTAMP"
))
{
return
"TIMESTAMP'"
+
value
+
"'"
;
}
else
{
return
(
String
)
value
;
}
}
return
super
.
getValueDisplayString
(
column
,
value
,
format
);
}
private
static
Object
getTimestampReadMethod
(
Class
<?>
aClass
,
Connection
connection
,
Object
object
)
throws
Exception
{
switch
(
aClass
.
getName
())
{
case
OracleConstants
.
TIMESTAMP_CLASS_NAME
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录