From 83c750c454059aaf84c3cba2fcee050996a998ba Mon Sep 17 00:00:00 2001 From: Nao Yonashiro Date: Wed, 11 May 2022 15:04:27 +0900 Subject: [PATCH 1/2] chore: fix a compile error --- docs/howto/transactions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/howto/transactions.md b/docs/howto/transactions.md index 0ccacb9000..e1ab07e49c 100644 --- a/docs/howto/transactions.md +++ b/docs/howto/transactions.md @@ -58,7 +58,7 @@ func (q *Queries) GetRecord(ctx context.Context, id int) (Record, error) { With pgx you'd use it like this for example: ```go -function bumpCounter(ctx context.Context, p *pgx.Conn, id int) error { +func bumpCounter(ctx context.Context, p *pgx.Conn, id int) error { tx, err := db.Begin(ctx) if err != nil { return err From aed5e95e7f1a238b1c3879256ff1ebcb7338870f Mon Sep 17 00:00:00 2001 From: Nao Yonashiro Date: Wed, 11 May 2022 15:04:59 +0900 Subject: [PATCH 2/2] style: apply gofmt to sample code --- docs/howto/insert.md | 6 +++--- docs/howto/transactions.md | 2 +- docs/reference/query-annotations.md | 13 ++++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/howto/insert.md b/docs/howto/insert.md index e78dc7f2ab..85fa748916 100644 --- a/docs/howto/insert.md +++ b/docs/howto/insert.md @@ -154,11 +154,11 @@ INSERT INTO authors (name, bio) VALUES ($1, $2); ```go type CreateAuthorsParams struct { - Name string - Bio string + Name string + Bio string } func (q *Queries) CreateAuthors(ctx context.Context, arg []CreateAuthorsParams) (int64, error) { - return q.db.CopyFrom(ctx, []string{"authors"}, []string{"name", "bio"}, &iteratorForCreateAuthors{rows: arg}) + return q.db.CopyFrom(ctx, []string{"authors"}, []string{"name", "bio"}, &iteratorForCreateAuthors{rows: arg}) } ``` diff --git a/docs/howto/transactions.md b/docs/howto/transactions.md index e1ab07e49c..ce822b07b4 100644 --- a/docs/howto/transactions.md +++ b/docs/howto/transactions.md @@ -71,7 +71,7 @@ func bumpCounter(ctx context.Context, p *pgx.Conn, id int) error { } if err := q.UpdateRecord(ctx, db.UpdateRecordParams{ ID: r.ID, - Counter: r.Counter+1, + Counter: r.Counter + 1, }); err != nil { return err } diff --git a/docs/reference/query-annotations.md b/docs/reference/query-annotations.md index 024737594d..fe9fa791f5 100644 --- a/docs/reference/query-annotations.md +++ b/docs/reference/query-annotations.md @@ -130,9 +130,10 @@ WHERE book_id = $1; ```go type DeleteBookBatchResults struct { - br pgx.BatchResults + br pgx.BatchResults ind int } + func (q *Queries) DeleteBook(ctx context.Context, bookID []int32) *DeleteBookBatchResults { //... } @@ -161,13 +162,14 @@ WHERE title = $1 AND year = $2; ```go type BooksByTitleYearBatchResults struct { - br pgx.BatchResults + br pgx.BatchResults ind int } type BooksByTitleYearParams struct { Title string `json:"title"` Year int32 `json:"year"` } + func (q *Queries) BooksByTitleYear(ctx context.Context, arg []BooksByTitleYearParams) *BooksByTitleYearBatchResults { //... } @@ -202,13 +204,14 @@ RETURNING book_id, author_id, isbn ```go type CreateBookBatchResults struct { - br pgx.BatchResults + br pgx.BatchResults ind int } type CreateBookParams struct { - AuthorID int32 `json:"author_id"` - Isbn string `json:"isbn"` + AuthorID int32 `json:"author_id"` + Isbn string `json:"isbn"` } + func (q *Queries) CreateBook(ctx context.Context, arg []CreateBookParams) *CreateBookBatchResults { //... }