From cd27c25ed1ebbe3c24c7bac018726d12436c2a64 Mon Sep 17 00:00:00 2001 From: Abhineshhh Date: Sun, 12 Jul 2026 18:50:03 +0530 Subject: [PATCH] docs: fix SQLite tutorial CreateAuthor usage with RETURNING * CreateAuthor is defined as :one with RETURNING *, so sqlc generates a method that returns Author, not sql.Result. The tutorial incorrectly called LastInsertId() on the result, which does not compile. Use the returned Author (matching the PostgreSQL tutorial) and compare the full structs after GetAuthor. Fixes #4468 --- docs/tutorials/getting-started-sqlite.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/tutorials/getting-started-sqlite.md b/docs/tutorials/getting-started-sqlite.md index feeff07511..b3c2a570df 100644 --- a/docs/tutorials/getting-started-sqlite.md +++ b/docs/tutorials/getting-started-sqlite.md @@ -159,28 +159,23 @@ func run() error { log.Println(authors) // create an author - result, err := queries.CreateAuthor(ctx, tutorial.CreateAuthorParams{ + insertedAuthor, err := queries.CreateAuthor(ctx, tutorial.CreateAuthorParams{ Name: "Brian Kernighan", Bio: sql.NullString{String: "Co-author of The C Programming Language and The Go Programming Language", Valid: true}, }) if err != nil { return err } - - insertedAuthorID, err := result.LastInsertId() - if err != nil { - return err - } - log.Println(insertedAuthorID) + log.Println(insertedAuthor) // get the author we just inserted - fetchedAuthor, err := queries.GetAuthor(ctx, insertedAuthorID) + fetchedAuthor, err := queries.GetAuthor(ctx, insertedAuthor.ID) if err != nil { return err } // prints true - log.Println(reflect.DeepEqual(insertedAuthorID, fetchedAuthor.ID)) + log.Println(reflect.DeepEqual(insertedAuthor, fetchedAuthor)) return nil }