diff --git a/docs/howto/select.md b/docs/howto/select.md index 2afb4ce456..cea3900b68 100644 --- a/docs/howto/select.md +++ b/docs/howto/select.md @@ -133,6 +133,10 @@ When selecting multiple columns, a row record (method-specific struct) is returned. In this case, `GetInfoForAuthor` returns a struct with two fields: `Bio` and `BirthYear`. +If a query result has no row records, a zero value and an `ErrNoRows` error are +returned instead of a zero value and `nil`. For instance, when the `GetBioForAuthor` +result has no rows, it will return `""` and `ErrNoRows`. + ```go package db diff --git a/internal/tools/sqlc-pg-gen/main.go b/internal/tools/sqlc-pg-gen/main.go index 5c36e3bff9..815828ec98 100644 --- a/internal/tools/sqlc-pg-gen/main.go +++ b/internal/tools/sqlc-pg-gen/main.go @@ -156,7 +156,7 @@ func clean(arg string) string { return arg } -// writeFormattedGo executes `tmpl` with `data` as its context to the the file `destPath` +// writeFormattedGo executes `tmpl` with `data` as its context to the file `destPath` func writeFormattedGo(tmpl *template.Template, data any, destPath string) error { out := bytes.NewBuffer([]byte{}) err := tmpl.Execute(out, data)