Skip to content

Commit

Permalink
fix(mysql): fix parsing datetime types
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadv184 committed Mar 6, 2023
1 parent 9ee8cf4 commit 5d6b767
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion data/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (d *Set) GetStringValues() []string {
case KindBool:
values[i] = fmt.Sprintf("%t", data.GetValue().GetValue())
case KindDateTime:
values[i] = fmt.Sprintf("%s", data.GetValue().GetValue().(time.Time).Format("2006-01-02 15:04:05"))
values[i] = fmt.Sprintf("%s", data.GetValue().GetValue().(time.Time).Format("2006-01-02 15:04:05.999999999"))
default:
values[i] = fmt.Sprintf("%s", data.GetValue().GetValue())
}
Expand Down
4 changes: 2 additions & 2 deletions driver/mysql/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,11 @@ func (t *DateTimeType) Parse(v any) error {
t.value = v.(time.Time)
return nil
case []byte:
v, err := time.Parse("2006-01-02 15:04:05", string(v.([]byte)))
tm, err := time.Parse("2006-01-02 15:04:05.999999999", string(v.([]byte)))
if err != nil {
return err
}
t.value = v
t.value = tm
return nil
default:
return fmt.Errorf("%v: expected time.Time, got %T", data.ErrInvalidValue, v)
Expand Down
3 changes: 1 addition & 2 deletions gloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const (
DefaultRowsPerBatch = 100
DefaultWorkers = 5
DefaultWorkers = 3
)

var (
Expand Down Expand Up @@ -110,7 +110,6 @@ func (g *GLoader) Start() error {
}

wg := sync.WaitGroup{}

for _, dc := range sDetails.DataCollections {
wg.Add(2)
fmt.Println("Starting to load", dc.Name, "from", 0, "to", dc.DataSetCount)
Expand Down
2 changes: 1 addition & 1 deletion reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (r *Reader) Start() error {
}
}
retryRead:
batch, err := sConn.Read(r.dataCollection, startOffset, endOffset)
batch, err := sConn.Read(r.dataCollection, i, i+rowPerBatch)
if err != nil {
log.Println(err)
goto retryRead
Expand Down

0 comments on commit 5d6b767

Please sign in to comment.