Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
4293f22d
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,发现更多精彩内容 >>
提交
4293f22d
编写于
10月 20, 2020
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PG array handle fix (use proper item type)
上级
bfdb886b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
14 deletion
+14
-14
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/PostgreValueParser.java
.../org/jkiss/dbeaver/ext/postgresql/PostgreValueParser.java
+11
-11
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/data/PostgreArrayValueHandler.java
...r/ext/postgresql/model/data/PostgreArrayValueHandler.java
+3
-3
未找到文件。
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/PostgreValueParser.java
浏览文件 @
4293f22d
...
...
@@ -43,13 +43,13 @@ public class PostgreValueParser {
private
static
final
Log
log
=
Log
.
getLog
(
PostgreValueParser
.
class
);
public
static
Object
convertStringToValue
(
DBCSession
session
,
DBSTypedObject
item
Type
,
String
string
)
throws
DBCException
{
if
(
item
Type
.
getDataKind
()
==
DBPDataKind
.
ARRAY
)
{
public
static
Object
convertStringToValue
(
DBCSession
session
,
DBSTypedObject
array
Type
,
String
string
)
throws
DBCException
{
if
(
array
Type
.
getDataKind
()
==
DBPDataKind
.
ARRAY
)
{
if
(
CommonUtils
.
isEmpty
(
string
))
{
return
new
Object
[
0
];
}
else
if
(
string
.
startsWith
(
"{"
)
&&
string
.
endsWith
(
"}"
))
{
try
{
return
prepareToParseArray
(
session
,
item
Type
,
string
);
return
prepareToParseArray
(
session
,
array
Type
,
string
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Array parsing failed "
+
e
.
getMessage
());
return
string
;
...
...
@@ -60,10 +60,10 @@ public class PostgreValueParser {
}
}
if
(
CommonUtils
.
isEmpty
(
string
))
{
return
convertStringToSimpleValue
(
session
,
item
Type
,
string
);
return
convertStringToSimpleValue
(
session
,
array
Type
,
string
);
}
try
{
switch
(
item
Type
.
getTypeID
())
{
switch
(
array
Type
.
getTypeID
())
{
case
Types
.
BOOLEAN
:
return
string
.
length
()
>
0
&&
Character
.
toLowerCase
(
string
.
charAt
(
0
))
==
't'
;
//todo: add support of alternatives to "true/false"
case
Types
.
TINYINT
:
...
...
@@ -81,7 +81,7 @@ public class PostgreValueParser {
case
Types
.
DOUBLE
:
return
Double
.
parseDouble
(
string
);
default
:
{
return
convertStringToSimpleValue
(
session
,
item
Type
,
string
);
return
convertStringToSimpleValue
(
session
,
array
Type
,
string
);
}
}
}
catch
(
NumberFormatException
e
)
{
...
...
@@ -89,12 +89,12 @@ public class PostgreValueParser {
}
}
private
static
Object
prepareToParseArray
(
DBCSession
session
,
DBSTypedObject
item
Type
,
String
string
)
throws
DBCException
{
DBSDataType
arrayDataType
=
itemType
instanceof
DBSDataType
?
(
DBSDataType
)
itemType
:
((
DBSTypedObjectEx
)
item
Type
).
getDataType
();
private
static
Object
prepareToParseArray
(
DBCSession
session
,
DBSTypedObject
array
Type
,
String
string
)
throws
DBCException
{
DBSDataType
arrayDataType
=
arrayType
instanceof
DBSDataType
?
(
DBSDataType
)
arrayType
:
((
DBSTypedObjectEx
)
array
Type
).
getDataType
();
try
{
DBSDataType
componentType
=
arrayDataType
.
getComponentType
(
session
.
getProgressMonitor
());
if
(
componentType
==
null
)
{
log
.
error
(
"Can't get component type from array '"
+
item
Type
.
getFullTypeName
()
+
"'"
);
log
.
error
(
"Can't get component type from array '"
+
array
Type
.
getFullTypeName
()
+
"'"
);
return
string
;
}
else
{
if
(
componentType
instanceof
PostgreDataType
)
{
...
...
@@ -102,12 +102,12 @@ public class PostgreValueParser {
List
<
Object
>
itemStrings
=
parseArrayString
(
string
,
","
);
return
startTransformListOfValuesIntoArray
(
session
,
(
PostgreDataType
)
componentType
,
itemStrings
);
}
else
{
log
.
error
(
"Incorrect type '"
+
item
Type
.
getFullTypeName
()
+
"'"
);
log
.
error
(
"Incorrect type '"
+
array
Type
.
getFullTypeName
()
+
"'"
);
return
string
;
}
}
}
catch
(
Exception
e
)
{
throw
new
DBCException
(
"Error extracting array '"
+
item
Type
.
getFullTypeName
()
+
"' items"
,
e
);
throw
new
DBCException
(
"Error extracting array '"
+
array
Type
.
getFullTypeName
()
+
"' items"
,
e
);
}
}
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/data/PostgreArrayValueHandler.java
浏览文件 @
4293f22d
...
...
@@ -70,7 +70,7 @@ public class PostgreArrayValueHandler extends JDBCArrayValueHandler {
// Convert arrays to string representation (#7468)
// Otherwise we may have problems with domain types decoding (as they come in form of PgObject)
String
strValue
=
object
.
toString
();
return
convertStringArrayToCollection
(
session
,
arrayType
,
strValue
);
return
convertStringArrayToCollection
(
session
,
arrayType
,
itemType
,
strValue
);
}
else
if
(
className
.
equals
(
PostgreConstants
.
PG_OBJECT_CLASS
))
{
final
Object
value
=
PostgreUtils
.
extractPGObjectValue
(
object
);
if
(
value
instanceof
String
)
{
...
...
@@ -120,8 +120,8 @@ public class PostgreArrayValueHandler extends JDBCArrayValueHandler {
}
}
private
JDBCCollection
convertStringArrayToCollection
(
@NotNull
DBCSession
session
,
@NotNull
PostgreDataType
itemType
,
@NotNull
String
strValue
)
throws
DBCException
{
Object
parsedArray
=
PostgreValueParser
.
convertStringToValue
(
session
,
item
Type
,
strValue
);
private
JDBCCollection
convertStringArrayToCollection
(
@NotNull
DBCSession
session
,
@NotNull
PostgreDataType
arrayType
,
@NotNull
PostgreDataType
itemType
,
@NotNull
String
strValue
)
throws
DBCException
{
Object
parsedArray
=
PostgreValueParser
.
convertStringToValue
(
session
,
array
Type
,
strValue
);
if
(
parsedArray
instanceof
Object
[]){
return
new
JDBCCollection
(
itemType
,
DBUtils
.
findValueHandler
(
session
,
itemType
),
(
Object
[])
parsedArray
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录