Skip to content

docs: fix SQLite tutorial CreateAuthor usage with RETURNING * - #4511

Merged
kyleconroy merged 1 commit into
sqlc-dev:mainfrom
Abhineshhh:fix/4468-sqlite-tutorial-create-author
Jul 30, 2026
Merged

docs: fix SQLite tutorial CreateAuthor usage with RETURNING *#4511
kyleconroy merged 1 commit into
sqlc-dev:mainfrom
Abhineshhh:fix/4468-sqlite-tutorial-create-author

Conversation

@Abhineshhh

Copy link
Copy Markdown
Contributor

Summary

  • The SQLite getting-started tutorial defines CreateAuthor as :one with RETURNING *, so sqlc generates (Author, error), not sql.Result.
  • The Go example incorrectly treated the return value as sql.Result and called LastInsertId(), which does not compile.
  • Update the example to use the returned Author (same pattern as the PostgreSQL tutorial) and compare full structs after GetAuthor.

Fixes #4468

Verification

  1. Generated code from the tutorial schema.sql / query.sql with a local sqlc build:
    • CreateAuthor(ctx, CreateAuthorParams) (Author, error)
    • GetAuthor(ctx, id int64) (Author, error)
    • Author{ID int64; Name string; Bio sql.NullString}
  2. Compiled and ran the fixed tutorial.go end-to-end with modernc.org/sqlite and an in-memory DB.
  3. Program output included true from reflect.DeepEqual(insertedAuthor, fetchedAuthor).

Test plan

  • Confirmed generated signatures match the fixed example
  • go build and run of the full tutorial program succeeds
  • Docs render as expected after merge

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 sqlc-dev#4468
@Abhineshhh

Copy link
Copy Markdown
Contributor Author

have a review @kyleconroy

@kyleconroy
kyleconroy merged commit 9f362b9 into sqlc-dev:main Jul 30, 2026
9 checks passed
@kyleconroy

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite getting-started tutorial uses LastInsertId() on RETURNING * result

2 participants