Skip to content

Commit

Permalink
Add failing test for sqlc-dev#3834
Browse files Browse the repository at this point in the history
  • Loading branch information
joeriddles committed Feb 11, 2025
1 parent ec9d492 commit 4a93803
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/booktest/sqlite/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,17 @@ func TestBooks(t *testing.T) {
t.Fatal(err)
}

// update book with isbn "1" to year 2024
_, err = dq.SaveBook(ctx, SaveBookParams{
AuthorID: a.AuthorID,
Isbn: "1",
Title: "my book title",
BookType: BooksBookTypeFICTION,
Yr: 2024,
Available: now,
Tag: "",
})
if err != nil {
t.Fatal(err)
}
}
22 changes: 22 additions & 0 deletions examples/booktest/sqlite/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,25 @@ WHERE book_id = ?3;
/* name: DeleteAuthorBeforeYear :exec */
DELETE FROM books
WHERE yr < ? AND author_id = ?;

/* name: SaveBook :one */
INSERT INTO books (
author_id,
isbn,
book_type,
title,
yr,
available,
tag
) VALUES (
?,
?,
?,
?,
?,
?,
?
)
ON CONFLICT (isbn)
DO UPDATE SET author_id = ?, book_type = ?, title = ?, yr = ?, available = ?, tag = ?
RETURNING *;
57 changes: 57 additions & 0 deletions examples/booktest/sqlite/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4a93803

Please # to comment.