Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/database/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (c Connection) MySQL() string {
config.User = c.User
config.Passwd = c.Pass
config.Net = "tcp"
config.ParseTime = true
config.Addr = fmt.Sprintf("%s:%d", c.Host, c.Port)
return config.FormatDSN()
}
7 changes: 7 additions & 0 deletions pkg/database/mysql/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,13 @@ func (table *table) RowBuffer() *bytes.Buffer {
} else {
fmt.Fprintf(&b, "_binary '%s'", sanitize(string(*s)))
}
case *sql.NullTime:
if s.Valid {
fmt.Fprintf(&b, "'%s'", sanitize(s.Time.Format("2006-01-02 15:04:05")))
} else {
b.WriteString(nullType)
}

default:
fmt.Fprintf(&b, "'%s'", value)
}
Expand Down
2 changes: 1 addition & 1 deletion test/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (d *dockerContext) createBackupFile(mysqlCID, mysqlUser, mysqlPass, outfile
ctx := context.Background()

// Create and populate the table
mysqlCreateCmd := []string{"mysql", "-hlocalhost", "--protocol=tcp", fmt.Sprintf("-u%s", mysqlUser), fmt.Sprintf("-p%s", mysqlPass), "-e", `use tester; create table t1 (id INT, name VARCHAR(20)); INSERT INTO t1 (id,name) VALUES (1, "John"), (2, "Jill"), (3, "Sam"), (4, "Sarah");`}
mysqlCreateCmd := []string{"mysql", "-hlocalhost", "--protocol=tcp", fmt.Sprintf("-u%s", mysqlUser), fmt.Sprintf("-p%s", mysqlPass), "-e", `use tester; create table t1 (id INT, name VARCHAR(20), test_timestamp TIMESTAMP, test_datetime DATETIME, test_date DATE, test_time TIME); INSERT INTO t1 (id,name,test_timestamp,test_datetime,test_date,test_time) VALUES (1, "John", '2012-11-01 00:15:00', '2012-11-01 00:15:00', '2012-11-01 00:15:00', '2012-11-01 00:15:00'), (2, "Jill", '2012-11-01 00:15:00', '2012-11-01 00:15:00', '2012-11-01 00:15:00', '2012-11-01 00:15:00'), (3, "Sam", '2012-11-01 00:15:00', '2012-11-01 00:15:00', '2012-11-01 00:15:00', '2012-11-01 00:15:00'), (4, "Sarah", '2012-11-01 00:15:00', '2012-11-01 00:15:00', '2012-11-01 00:15:00', '2012-11-01 00:15:00');`}
attachResp, exitCode, err := d.execInContainer(ctx, mysqlCID, mysqlCreateCmd)
if err != nil {
return fmt.Errorf("failed to attach to exec: %w", err)
Expand Down