Skip to content

Commit d12db53

Browse files
authored
docs: Add a description to the document for cases when a query result has no rows (#2462)
* add a description if a query result has no rows * fix a typo
1 parent cef1a20 commit d12db53

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

docs/howto/select.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ When selecting multiple columns, a row record (method-specific struct) is
133133
returned. In this case, `GetInfoForAuthor` returns a struct with two fields:
134134
`Bio` and `BirthYear`.
135135

136+
If a query result has no row records, a zero value and an `ErrNoRows` error are
137+
returned instead of a zero value and `nil`. For instance, when the `GetBioForAuthor`
138+
result has no rows, it will return `""` and `ErrNoRows`.
139+
136140
```go
137141
package db
138142

internal/tools/sqlc-pg-gen/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func clean(arg string) string {
156156
return arg
157157
}
158158

159-
// writeFormattedGo executes `tmpl` with `data` as its context to the the file `destPath`
159+
// writeFormattedGo executes `tmpl` with `data` as its context to the file `destPath`
160160
func writeFormattedGo(tmpl *template.Template, data any, destPath string) error {
161161
out := bytes.NewBuffer([]byte{})
162162
err := tmpl.Execute(out, data)

0 commit comments

Comments
 (0)