From ac471eaf3ca0e8ae46a6da7c3c1078b6435d8cd5 Mon Sep 17 00:00:00 2001 From: Felipe Espinoza Date: Fri, 23 Feb 2024 16:34:22 +0000 Subject: [PATCH 1/2] Add support to uint and time --- dump.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dump.go b/dump.go index 2411be1..a28dad5 100644 --- a/dump.go +++ b/dump.go @@ -444,7 +444,7 @@ func (table *table) Init() error { func reflectColumnType(tp *sql.ColumnType) reflect.Type { // reflect for ScanType switch tp.ScanType().Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return reflect.TypeOf(sql.NullInt64{}) case reflect.Float32, reflect.Float64: return reflect.TypeOf(sql.NullFloat64{}) @@ -531,6 +531,12 @@ 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'", s.Time.Format("2006-01-02 15:04:05")) + } else { + b.WriteString(nullType) + } default: fmt.Fprintf(&b, "'%s'", value) } From 815f35f8532ceb78fcbba4243ca2a30698b17ded Mon Sep 17 00:00:00 2001 From: Felipe Espinoza Date: Fri, 23 Feb 2024 16:46:58 +0000 Subject: [PATCH 2/2] Use RFC3339 --- dump.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dump.go b/dump.go index a28dad5..e8a28e1 100644 --- a/dump.go +++ b/dump.go @@ -533,7 +533,7 @@ func (table *table) RowBuffer() *bytes.Buffer { } case *sql.NullTime: if s.Valid { - fmt.Fprintf(&b, "'%s'", s.Time.Format("2006-01-02 15:04:05")) + fmt.Fprintf(&b, "'%s'", s.Time.Format(time.RFC3339)) } else { b.WriteString(nullType) }