Copy edits

This commit is contained in:
Adriano Caloiaro 2024-03-07 09:44:10 -07:00
parent 87a2c2aed5
commit b65c5a638f
No known key found for this signature in database
GPG key ID: C2BC56DE73CE3F75

View file

@ -71,7 +71,7 @@ type SaveUserParams struct {
}
```
As you can see, the ID field is a `uuid.UUID`, not `*uuid.UUID`, so it's not possible to leave empty when calling `SaveUser` for _new_ users. Using sqlc overrides we can of course instruct it to generate Go code with `*uuid.UUID` types, but passing `nil` would mean our `INSERT` passes `NULL` to a non-nullable primary key field, which raises a not-null constraint.
As you can see, the ID field is a `uuid.UUID`, not `*uuid.UUID`, so it's not possible to leave empty when calling `SaveUser` for _new_ users. Using sqlc overrides we can of course instruct it to generate Go code with `*uuid.UUID` types, but passing `nil` would mean our `INSERT` passes `NULL` to a non-nullable primary key field, which raises null key constraint violation.
## The solution
@ -105,4 +105,4 @@ INSERT INTO users (
RETURNING *;
```
This turned out to be a very simple solution for my current problems. If there's a better or more idiomatic way to achieve the same result, please let me know in the comments!
This turned out to be a very simple solution for my current problem. If there's a better or more idiomatic way to achieve the same result, please let me know in the comments!