Skip to content

Commit 68f1530

Browse files
update uuid docs for mysql (#2019)
1 parent 7916e26 commit 68f1530

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

docs/reference/datatypes.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ type Author struct {
133133
}
134134
```
135135

136+
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`.
137+
```json
138+
{
139+
"overrides": [
140+
{
141+
"column": "*.uuid",
142+
"go_type": "github.com/google/uuid.UUID"
143+
}
144+
]
145+
}
146+
```
147+
136148
## JSON
137149

138150
By default, sqlc will generate the `[]byte`, `pgtype.JSON` or `json.RawMessage` for JSON column type.
@@ -176,4 +188,4 @@ import (
176188
type Book struct {
177189
Data *dto.BookData
178190
}
179-
```
191+
```

0 commit comments

Comments
 (0)