/
githubmirror
/
sqlc
Обзор
Документация
Войти
/
githubmirror
/
sqlc
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/endtoend/testdata/diff_output/stderr.txt
54 строки
1 KB
Kyle Gray
feat(analyzer): Analyze queries using a running PostgreSQL database (#2805)
12 окт 2023, 20:32
Не верифицирован
12 окт 2023, 20:32
bb84596
Код
Авторство
О чём код?
--- a/go/models.go +++ b/go/models.go @@ -13,3 +13,8 @@ Name string Bio sql.NullString } + +type Book struct { + ID int64 + Title string +} --- a/go/query.sql.go +++ b/go/query.sql.go @@ -31,16 +31,6 @@ return i, err } -const deleteAuthor = `-- name: DeleteAuthor :exec -DELETE FROM authors -WHERE id = $1 -` - -func (q *Queries) DeleteAuthor(ctx context.Context, id int64) error { - _, err := q.db.ExecContext(ctx, deleteAuthor, id) - return err -} - const getAuthor = `-- name: GetAuthor :one SELECT id, name, bio FROM authors WHERE id = $1 LIMIT 1 @@ -55,7 +45,7 @@ const listAuthors = `-- name: ListAuthors :many SELECT id, name, bio FROM authors +ORDER BY bio -ORDER BY name ` func (q *Queries) ListAuthors(ctx context.Context) ([]Author, error) { @@ -80,3 +70,14 @@ } return items, nil } + +const selectOne = `-- name: SelectOne :one +SELECT 1 +` + +func (q *Queries) SelectOne(ctx context.Context) (int32, error) { + row := q.db.QueryRowContext(ctx, selectOne) + var column_1 int32 + err := row.Scan(&column_1) + return column_1, err +}