From 5ddb7138df9c951509f0e8b5a5c0ea79d5e35aba Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Thu, 13 Aug 2020 09:26:34 +0900 Subject: [PATCH 1/3] Add deprecated message to NullTime --- nulltime_go113.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nulltime_go113.go b/nulltime_go113.go index c392594dd..cb9bcae4a 100644 --- a/nulltime_go113.go +++ b/nulltime_go113.go @@ -28,4 +28,8 @@ import ( // } // // This NullTime implementation is not driver-specific +// +// Deprecated: NullTime doesn't honor the loc DSN parameter. +// NullTime.Scan interprets a time as UTC, not the loc DSN parameter. +// Use sql.NullTime instead. type NullTime sql.NullTime From e558fd9bf3e15cb4d5e0dd520689b06da4c4ffa7 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Thu, 13 Aug 2020 09:27:17 +0900 Subject: [PATCH 2/3] remove NullTime from README --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 505d2a7e1..e8913f6d0 100644 --- a/README.md +++ b/README.md @@ -458,9 +458,7 @@ The default internal output type of MySQL `DATE` and `DATETIME` values is `[]byt However, many want to scan MySQL `DATE` and `DATETIME` values into `time.Time` variables, which is the logical equivalent in Go to `DATE` and `DATETIME` in MySQL. You can do that by changing the internal output type from `[]byte` to `time.Time` with the DSN parameter `parseTime=true`. You can set the default [`time.Time` location](https://golang.org/pkg/time/#Location) with the `loc` DSN parameter. **Caution:** As of Go 1.1, this makes `time.Time` the only variable type you can scan `DATE` and `DATETIME` values into. This breaks for example [`sql.RawBytes` support](https://github.com/go-sql-driver/mysql/wiki/Examples#rawbytes). - -Alternatively you can use the [`NullTime`](https://godoc.org/github.com/go-sql-driver/mysql#NullTime) type as the scan destination, which works with both `time.Time` and `string` / `[]byte`. - +s ### Unicode support Since version 1.5 Go-MySQL-Driver automatically uses the collation ` utf8mb4_general_ci` by default. From cce4dbc8e00a9818bf5728c00501f53c9fc2aef6 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Thu, 13 Aug 2020 16:02:08 +0900 Subject: [PATCH 3/3] fix typo: s --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8913f6d0..834cf10f5 100644 --- a/README.md +++ b/README.md @@ -458,7 +458,7 @@ The default internal output type of MySQL `DATE` and `DATETIME` values is `[]byt However, many want to scan MySQL `DATE` and `DATETIME` values into `time.Time` variables, which is the logical equivalent in Go to `DATE` and `DATETIME` in MySQL. You can do that by changing the internal output type from `[]byte` to `time.Time` with the DSN parameter `parseTime=true`. You can set the default [`time.Time` location](https://golang.org/pkg/time/#Location) with the `loc` DSN parameter. **Caution:** As of Go 1.1, this makes `time.Time` the only variable type you can scan `DATE` and `DATETIME` values into. This breaks for example [`sql.RawBytes` support](https://github.com/go-sql-driver/mysql/wiki/Examples#rawbytes). -s + ### Unicode support Since version 1.5 Go-MySQL-Driver automatically uses the collation ` utf8mb4_general_ci` by default.