Skip to content

Commit ebab637

Browse files
committed
docs(tutorial): fix SQLite tutorial CreateAuthor return value (#3336)
Signed-off-by: SAY-5 <say.apm35@gmail.com>
1 parent 5dfc713 commit ebab637

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

docs/tutorials/getting-started-sqlite.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,23 +159,28 @@ func run() error {
159159
log.Println(authors)
160160
161161
// create an author
162-
insertedAuthor, err := queries.CreateAuthor(ctx, tutorial.CreateAuthorParams{
162+
result, err := queries.CreateAuthor(ctx, tutorial.CreateAuthorParams{
163163
Name: "Brian Kernighan",
164164
Bio: sql.NullString{String: "Co-author of The C Programming Language and The Go Programming Language", Valid: true},
165165
})
166166
if err != nil {
167167
return err
168168
}
169-
log.Println(insertedAuthor)
169+
170+
insertedAuthorID, err := result.LastInsertId()
171+
if err != nil {
172+
return err
173+
}
174+
log.Println(insertedAuthorID)
170175
171176
// get the author we just inserted
172-
fetchedAuthor, err := queries.GetAuthor(ctx, insertedAuthor.ID)
177+
fetchedAuthor, err := queries.GetAuthor(ctx, insertedAuthorID)
173178
if err != nil {
174179
return err
175180
}
176181
177182
// prints true
178-
log.Println(reflect.DeepEqual(insertedAuthor, fetchedAuthor))
183+
log.Println(reflect.DeepEqual(insertedAuthorID, fetchedAuthor.ID))
179184
return nil
180185
}
181186

0 commit comments

Comments
 (0)