From 205b12c2d1ad1470d6ddb2cd08603ffeac75b9b4 Mon Sep 17 00:00:00 2001 From: yukyan Date: Sat, 15 Jul 2023 02:57:14 +0900 Subject: [PATCH 1/2] add a description if a query result has no rows --- docs/howto/select.md | 4 ++++ 1 file changed, 4 insertions(+) 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 From 3d0cdce90714730c276c512a15fbc512cf1482b8 Mon Sep 17 00:00:00 2001 From: yukyan Date: Sat, 15 Jul 2023 03:17:56 +0900 Subject: [PATCH 2/2] fix a typo --- internal/tools/sqlc-pg-gen/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)