From 7da0a1a211a37d842799caf63f117ec24c5d03bb Mon Sep 17 00:00:00 2001 From: Mike Mackintosh Date: Fri, 13 Jan 2023 21:41:45 -0500 Subject: [PATCH] update uuid docs for mysql --- docs/reference/datatypes.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/reference/datatypes.md b/docs/reference/datatypes.md index 971f7a3fc3..3ed78638a9 100644 --- a/docs/reference/datatypes.md +++ b/docs/reference/datatypes.md @@ -133,6 +133,18 @@ type Author struct { } ``` +For MySQL, there is no native `uuid` data type. When using `UUID_TO_BIN` to store a `UUID()`, the underlying field type is `BINARY(16)` which by default sqlc would interpret this to `sql.NullString`. To have sqlc automatically convert these fields to a `uuid.UUID` type, use an overide on the column storing the `uuid`. +```json +{ + "overrides": [ + { + "column": "*.uuid", + "go_type": "github.com/google/uuid.UUID" + } + ] +} +``` + ## JSON By default, sqlc will generate the `[]byte`, `pgtype.JSON` or `json.RawMessage` for JSON column type. @@ -176,4 +188,4 @@ import ( type Book struct { Data *dto.BookData } -``` \ No newline at end of file +```