Column receives "" when updating with zero values using pgtype.Text #1727
-
When using const updateProject = `-- name: UpdateProject :exec
UPDATE projects
SET build_bucket = $2
WHERE id = $1
` type UpdateProjectParams struct {
ID pgtype.UUID
BuildBucket pgtype.Text
}
func (q *Queries) UpdateProject(ctx context.Context, arg UpdateProjectParams) error {
_, err := q.db.Exec(ctx, updateProject, arg.ID, arg.BuildBucket)
return err
} err = UpdateProject(ctx, UpdateProjectParams{
ID: someUUID,
}) I expected that if no value is provided for Any thoughts on this, seems like an expected behaviour, but not what I imagined would happen. Maybe the issue lies somewhere else in my code but I am 90% sure its because of this behaviour that I described here |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
Valid == false
means the field is the SQLNULL
. It does not control whether the field is updated or not.