10000 docs(datatypes): improve details on TEXT (#3247) · lisitsky/sqlc@e058577 · GitHub
[go: up one dir, main page]

Skip to content

Commit e058577

Browse files
josethz00lisitsky
authored andcommitted
docs(datatypes): improve details on TEXT (sqlc-dev#3247)
* feat(datatypes): improve details on TEXT * docs(datatypes): correct nullable TEXT description * docs(datatypes): remove incorrect assumption
1 parent 4d6d96c commit e058577

File tree

Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ type Book struct {
204204
}
205205
```
206206

207+
## TEXT
208+
209+
In PostgreSQL, when you have a column with the TEXT type, sqlc will map it to a Go string by default. This default mapping applies to `TEXT` columns that are not nullable. However, for nullable `TEXT` columns, sqlc maps them to `pgtype.Text` when using the pgx/v5 driver. This distinction is crucial for developers looking to handle null values appropriately in their Go applications.
210+
211+
To accommodate nullable strings and map them to `*string` in Go, you can use the `emit_pointers_for_null_types` option in your sqlc configuration. This option ensures that nullable SQL columns are represented as pointer types in Go, allowing for a clear distinction between null and non-null values. Another way to do this is by passing the option `pointer: true` when you are overriding the `TEXT` datatype in you sqlc config file.
212+
207213
## Geometry
208214

209215
### PostGIS