Description
The SQLite getting-started tutorial appears to have an inconsistency between the SQL query and the Go usage example.
Page:
https://docs.sqlc.dev/en/latest/tutorials/getting-started-sqlite.html
The tutorial defines CreateAuthor as:
-- name: CreateAuthor :one
INSERT INTO authors (
name, bio
) VALUES (
?, ?
)
RETURNING *;
With :one and RETURNING *, sqlc generates a method returning an Author:
func (q *Queries) CreateAuthor(ctx context.Context, arg CreateAuthorParams) (Author, error)
However, the later Go example uses the returned value as if it were a sql.Result:
result, 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},
})
insertedAuthorID, err := result.LastInsertId()
This does not compile because result is an Author, not a sql.Result.
Expected behavior
The tutorial should use the returned Author directly, for example:
createdAuthor, 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
}
log.Println(createdAuthor.ID)
Then the later fetch could use:
fetchedAuthor, err := queries.GetAuthor(ctx, createdAuthor.ID)
Actual behavior
The tutorial currently calls:
on the value returned by CreateAuthor, but that value is generated as an Author.
Version
I reproduced this with sqlc v1.31.1, which is also the version shown in generated files from the current tutorial.
Description
The SQLite getting-started tutorial appears to have an inconsistency between the SQL query and the Go usage example.
Page:
https://docs.sqlc.dev/en/latest/tutorials/getting-started-sqlite.html
The tutorial defines
CreateAuthoras:With :one and RETURNING *, sqlc generates a method returning an Author:
However, the later Go example uses the returned value as if it were a sql.Result:
This does not compile because result is an Author, not a sql.Result.
Expected behavior
The tutorial should use the returned Author directly, for example:
Then the later fetch could use:
Actual behavior
The tutorial currently calls:
on the value returned by CreateAuthor, but that value is generated as an Author.
Version
I reproduced this with sqlc v1.31.1, which is also the version shown in generated files from the current tutorial.