snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
31
internal/endtoend/testdata/multibyte_comment/sqlite/go/db.go
vendored
Normal file
31
internal/endtoend/testdata/multibyte_comment/sqlite/go/db.go
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
ExecContext(context.Context, string, ...any) (sql.Result, error)
|
||||
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
||||
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
|
||||
QueryRowContext(context.Context, string, ...any) *sql.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
11
internal/endtoend/testdata/multibyte_comment/sqlite/go/models.go
vendored
Normal file
11
internal/endtoend/testdata/multibyte_comment/sqlite/go/models.go
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package querytest
|
||||
|
||||
type Item struct {
|
||||
ID int64
|
||||
Name string
|
||||
CapRead string
|
||||
}
|
||||
87
internal/endtoend/testdata/multibyte_comment/sqlite/go/query.sql.go
vendored
Normal file
87
internal/endtoend/testdata/multibyte_comment/sqlite/go/query.sql.go
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: query.sql
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const createItem = `-- name: CreateItem :exec
|
||||
INSERT INTO items (name, cap_read)
|
||||
VALUES (?, ?)
|
||||
`
|
||||
|
||||
type CreateItemParams struct {
|
||||
Name string
|
||||
CapRead string
|
||||
}
|
||||
|
||||
// 当新建条目时,需要写入名称和权限
|
||||
func (q *Queries) CreateItem(ctx context.Context, arg CreateItemParams) error {
|
||||
_, err := q.db.ExecContext(ctx, createItem, arg.Name, arg.CapRead)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteItem = `-- name: DeleteItem :one
|
||||
DELETE FROM items WHERE id = ? RETURNING id, name, cap_read
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteItem(ctx context.Context, id int64) (Item, error) {
|
||||
row := q.db.QueryRowContext(ctx, deleteItem, id)
|
||||
var i Item
|
||||
err := row.Scan(&i.ID, &i.Name, &i.CapRead)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listItems = `-- name: ListItems :many
|
||||
|
||||
SELECT id, name, cap_read
|
||||
FROM items
|
||||
WHERE cap_read = 'anonymous'
|
||||
ORDER BY name
|
||||
`
|
||||
|
||||
// Multi-byte UTF-8 in comments must not shift the byte offsets used to slice
|
||||
// query text out of the source file (#4523, #4235, #4372).
|
||||
// an em dash right here — must not truncate the ORDER BY below
|
||||
func (q *Queries) ListItems(ctx context.Context) ([]Item, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listItems)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Item
|
||||
for rows.Next() {
|
||||
var i Item
|
||||
if err := rows.Scan(&i.ID, &i.Name, &i.CapRead); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateItem = `-- name: UpdateItem :exec
|
||||
|
||||
UPDATE items SET name = ? WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateItemParams struct {
|
||||
Name string
|
||||
ID int64
|
||||
}
|
||||
|
||||
// section — divider between queries
|
||||
func (q *Queries) UpdateItem(ctx context.Context, arg UpdateItemParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateItem, arg.Name, arg.ID)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user