未验证 提交 5b379d5a 编写于 作者: JupiterChen's avatar JupiterChen 提交者: GitHub

insert datas contains multiple timestamp columns, but this tool transfer it to...

insert datas contains multiple timestamp columns, but this tool transfer it to 'char' and pops up errors. (#8634)

* insert datas contains multiple timestamp columns, but this tool transfer it to 'char' and pops up errors.

* insert datas contains multiple timestamp columns, but this tool transfer it to 'char' and pops up errors.

* insert datas contains multiple timestamp columns, but this tool transfer it to 'char' and pops up errors.
上级 f76ddc61
......@@ -628,7 +628,7 @@ func insertData(threadIndex, start, end int, wg *sync.WaitGroup, successRows []i
buffer.WriteString(",")
for _, field := range subTableInfo.config.Fields {
buffer.WriteString(getFieldValue(currentRow[strings.ToLower(field.Name)]))
buffer.WriteString(getFieldValue(currentRow[strings.ToLower(field.Name)],field.Type))
buffer.WriteString(",")
}
......@@ -708,7 +708,10 @@ func executeBatchInsert(insertSql string, connection *sql.DB) int64 {
return affected
}
func getFieldValue(fieldValue interface{}) string {
func getFieldValue(fieldValue interface{},fieldtype interface{}) string {
if fieldtype == "timestamp" || fieldtype == "bigint" {
return fmt.Sprintf("%v", fieldValue)
}
return fmt.Sprintf("'%v'", fieldValue)
}
......
......@@ -18,6 +18,8 @@ tags = [
fields = [
# 字段列表,name 为字段名称,type 为字段类型
# 除主键外,其他field如果也要设置为timestamp,可以是type ="timestamp" 类型,此时value可同时支持'2006-01-02 15:04:05.000'和millisecond格式
# 也可以是type = "bigint",此时value只支持millisecond格式
{ name = "ts", type = "timestamp" },
{ name = "temperature", type = "int" },
{ name = "humidity", type = "float" },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册