Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL同步到CK时Decimal(18, 2)字段偶尔错误 #204

Closed
BruceMaa opened this issue Oct 14, 2022 · 1 comment
Closed

MySQL同步到CK时Decimal(18, 2)字段偶尔错误 #204

BruceMaa opened this issue Oct 14, 2022 · 1 comment

Comments

@BruceMaa
Copy link

BruceMaa commented Oct 14, 2022

Version:

  • Bifrost Version: [v1.8.7-release]
  • Os Version: [CentOS Linux release 7.7.1908]
  • Browse: [Chrome]

Describe the bug

MySQL表中有Decimal(18, 2)类型字段,同步到CK时选择自动创建表(手动创建相同属性也一样),CK表中字段也是Decimal(18, 2)类型。
同步3000多条数据,其中有3 至 5条数据,小数位错误。
比如MySQL中原数据为 149.14,CK中对应的数据为 149.13

将相同的表同步到另一个MySQL数据库中,没有此问题。

Screenshots

image

Additional context

查看处理Decimal类型的源码

//Decimal
if strings.Contains(toDataType, "Decimal") {
v = interfaceToFloat64(data)
} else {
switch reflect.TypeOf(data).Kind() {
case reflect.Array, reflect.Slice, reflect.Map:
var c []byte
c, e = json.Marshal(data)
if e != nil {
e = fmt.Errorf("field:%s ,data source type: %s , json.Marshal err: %s ", fieldName, reflect.TypeOf(data).Kind().String(), e.Error())
return
}
v = string(c)
break
case reflect.Float32:
v = strconv.FormatFloat(float64(data.(float32)), 'E', -1, 32)
case reflect.Float64:
v = strconv.FormatFloat(data.(float64), 'E', -1, 64)
default:
v = fmt.Sprint(data)
}
}

是做了Float64的转换,是否可以修改为String的转换,CK支持String数据添加到Decimal类型字段中。

@jc3wish
Copy link
Member

jc3wish commented Nov 2, 2022

因为驱动包原因,需要对驱动包升级,后续版本修复

jc3wish pushed a commit that referenced this issue Dec 3, 2023
* v2.2.3:
  修复MySQL源,指定同步表配置后,但可能没生效的BUG BUG复现过程: 1. 配置了一个T1表同步 2. 重启进程,并且T1表数据不再做任何更新 3. 配置T2表同步 4. 更新T1表的数据
  修复mysql 带有触发器的时候binlog解析失败的bug #263
  修复plugin clickhouse decimal 精度丢失的bug #204
  v2.2.2

# Conflicts:
#	README.EN.MD
#	README.MD
#	changelog.txt
#	config/version.go
This was referenced Dec 31, 2023
@jc3wish jc3wish closed this as completed Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants