Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lijianghuflute
canal
提交
6d280d10
canal
项目概览
lijianghuflute
/
canal
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
canal
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
6d280d10
编写于
3月 17, 2019
作者:
A
agapple
提交者:
GitHub
3月 17, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1597 from KangZhiDong/master
fix the error log does not contain table name
上级
cf4db162
078673c6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
8 addition
and
8 deletion
+8
-8
client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java
...baba/otter/canal/client/adapter/support/JdbcTypeUtil.java
+2
-2
client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/MessageUtil.java
...ibaba/otter/canal/client/adapter/support/MessageUtil.java
+6
-6
未找到文件。
client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java
浏览文件 @
6d280d10
...
...
@@ -76,7 +76,7 @@ public class JdbcTypeUtil {
||
"TEXT"
.
equalsIgnoreCase
(
columnType
)
||
"TINYTEXT"
.
equalsIgnoreCase
(
columnType
);
}
public
static
Object
typeConvert
(
String
columnName
,
String
value
,
int
sqlType
,
String
mysqlType
)
{
public
static
Object
typeConvert
(
String
tableName
,
String
columnName
,
String
value
,
int
sqlType
,
String
mysqlType
)
{
if
(
value
==
null
||
(
value
.
equals
(
""
)
&&
!(
isText
(
mysqlType
)
||
sqlType
==
Types
.
CHAR
||
sqlType
==
Types
.
VARCHAR
||
sqlType
==
Types
.
LONGVARCHAR
)))
{
return
null
;
...
...
@@ -161,7 +161,7 @@ public class JdbcTypeUtil {
}
return
res
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"table: {} column: {}, failed convert type {} to {}"
,
columnName
,
value
,
sqlType
);
logger
.
error
(
"table: {} column: {}, failed convert type {} to {}"
,
tableName
,
columnName
,
value
,
sqlType
);
return
value
;
}
}
...
...
client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/MessageUtil.java
浏览文件 @
6d280d10
...
...
@@ -77,7 +77,7 @@ public class MessageUtil {
}
}
row
.
put
(
column
.
getName
(),
JdbcTypeUtil
.
typeConvert
(
column
.
getName
(),
JdbcTypeUtil
.
typeConvert
(
dml
.
getTable
(),
column
.
getName
(),
column
.
getValue
(),
column
.
getSqlType
(),
column
.
getMysqlType
()));
...
...
@@ -95,7 +95,7 @@ public class MessageUtil {
for
(
CanalEntry
.
Column
column
:
rowData
.
getBeforeColumnsList
())
{
if
(
updateSet
.
contains
(
column
.
getName
()))
{
rowOld
.
put
(
column
.
getName
(),
JdbcTypeUtil
.
typeConvert
(
column
.
getName
(),
JdbcTypeUtil
.
typeConvert
(
dml
.
getTable
(),
column
.
getName
(),
column
.
getValue
(),
column
.
getSqlType
(),
column
.
getMysqlType
()));
...
...
@@ -153,16 +153,16 @@ public class MessageUtil {
// }
List
<
Map
<
String
,
String
>>
data
=
flatMessage
.
getData
();
if
(
data
!=
null
)
{
dml
.
setData
(
changeRows
(
data
,
flatMessage
.
getSqlType
(),
flatMessage
.
getMysqlType
()));
dml
.
setData
(
changeRows
(
d
ml
.
getTable
(),
d
ata
,
flatMessage
.
getSqlType
(),
flatMessage
.
getMysqlType
()));
}
List
<
Map
<
String
,
String
>>
old
=
flatMessage
.
getOld
();
if
(
old
!=
null
)
{
dml
.
setOld
(
changeRows
(
old
,
flatMessage
.
getSqlType
(),
flatMessage
.
getMysqlType
()));
dml
.
setOld
(
changeRows
(
dml
.
getTable
(),
old
,
flatMessage
.
getSqlType
(),
flatMessage
.
getMysqlType
()));
}
return
dml
;
}
private
static
List
<
Map
<
String
,
Object
>>
changeRows
(
List
<
Map
<
String
,
String
>>
rows
,
Map
<
String
,
Integer
>
sqlTypes
,
private
static
List
<
Map
<
String
,
Object
>>
changeRows
(
String
table
,
List
<
Map
<
String
,
String
>>
rows
,
Map
<
String
,
Integer
>
sqlTypes
,
Map
<
String
,
String
>
mysqlTypes
)
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
row
:
rows
)
{
...
...
@@ -181,7 +181,7 @@ public class MessageUtil {
continue
;
}
Object
finalValue
=
JdbcTypeUtil
.
typeConvert
(
columnName
,
columnValue
,
sqlType
,
mysqlType
);
Object
finalValue
=
JdbcTypeUtil
.
typeConvert
(
table
,
columnName
,
columnValue
,
sqlType
,
mysqlType
);
resultRow
.
put
(
columnName
,
finalValue
);
}
result
.
add
(
resultRow
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录