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

This commit is contained in:
upstream-mirror
2026-09-16 02:17:34 +05:00
commit 0f4df23290
7340 changed files with 238743 additions and 0 deletions

View 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,
}
}

View File

@@ -0,0 +1,271 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package querytest
import (
"database/sql/driver"
"fmt"
)
type AuthorsAddItem string
const (
AuthorsAddItemOk AuthorsAddItem = "ok"
AuthorsAddItemAdded AuthorsAddItem = "added"
)
func (e *AuthorsAddItem) Scan(src any) error {
switch s := src.(type) {
case []byte:
*e = AuthorsAddItem(s)
case string:
*e = AuthorsAddItem(s)
default:
return fmt.Errorf("unsupported scan type for AuthorsAddItem: %T", src)
}
return nil
}
type NullAuthorsAddItem struct {
AuthorsAddItem AuthorsAddItem
Valid bool // Valid is true if AuthorsAddItem is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAuthorsAddItem) Scan(value any) error {
if value == nil {
ns.AuthorsAddItem, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AuthorsAddItem.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAuthorsAddItem) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.AuthorsAddItem), nil
}
type AuthorsAdded string
const (
AuthorsAddedOk AuthorsAdded = "ok"
)
func (e *AuthorsAdded) Scan(src any) error {
switch s := src.(type) {
case []byte:
*e = AuthorsAdded(s)
case string:
*e = AuthorsAdded(s)
default:
return fmt.Errorf("unsupported scan type for AuthorsAdded: %T", src)
}
return nil
}
type NullAuthorsAdded struct {
AuthorsAdded AuthorsAdded
Valid bool // Valid is true if AuthorsAdded is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAuthorsAdded) Scan(value any) error {
if value == nil {
ns.AuthorsAdded, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AuthorsAdded.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAuthorsAdded) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.AuthorsAdded), nil
}
type AuthorsBar string
const (
AuthorsBarOk AuthorsBar = "ok"
)
func (e *AuthorsBar) Scan(src any) error {
switch s := src.(type) {
case []byte:
*e = AuthorsBar(s)
case string:
*e = AuthorsBar(s)
default:
return fmt.Errorf("unsupported scan type for AuthorsBar: %T", src)
}
return nil
}
type NullAuthorsBar struct {
AuthorsBar AuthorsBar
Valid bool // Valid is true if AuthorsBar is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAuthorsBar) Scan(value any) error {
if value == nil {
ns.AuthorsBar, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AuthorsBar.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAuthorsBar) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.AuthorsBar), nil
}
type AuthorsFoo string
const (
AuthorsFooOk AuthorsFoo = "ok"
)
func (e *AuthorsFoo) Scan(src any) error {
switch s := src.(type) {
case []byte:
*e = AuthorsFoo(s)
case string:
*e = AuthorsFoo(s)
default:
return fmt.Errorf("unsupported scan type for AuthorsFoo: %T", src)
}
return nil
}
type NullAuthorsFoo struct {
AuthorsFoo AuthorsFoo
Valid bool // Valid is true if AuthorsFoo is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAuthorsFoo) Scan(value any) error {
if value == nil {
ns.AuthorsFoo, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AuthorsFoo.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAuthorsFoo) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.AuthorsFoo), nil
}
type AuthorsRemoveItem string
const (
AuthorsRemoveItemOk AuthorsRemoveItem = "ok"
)
func (e *AuthorsRemoveItem) Scan(src any) error {
switch s := src.(type) {
case []byte:
*e = AuthorsRemoveItem(s)
case string:
*e = AuthorsRemoveItem(s)
default:
return fmt.Errorf("unsupported scan type for AuthorsRemoveItem: %T", src)
}
return nil
}
type NullAuthorsRemoveItem struct {
AuthorsRemoveItem AuthorsRemoveItem
Valid bool // Valid is true if AuthorsRemoveItem is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAuthorsRemoveItem) Scan(value any) error {
if value == nil {
ns.AuthorsRemoveItem, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AuthorsRemoveItem.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAuthorsRemoveItem) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.AuthorsRemoveItem), nil
}
type BooksFoo string
const (
BooksFooOk BooksFoo = "ok"
)
func (e *BooksFoo) Scan(src any) error {
switch s := src.(type) {
case []byte:
*e = BooksFoo(s)
case string:
*e = BooksFoo(s)
default:
return fmt.Errorf("unsupported scan type for BooksFoo: %T", src)
}
return nil
}
type NullBooksFoo struct {
BooksFoo BooksFoo
Valid bool // Valid is true if BooksFoo is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullBooksFoo) Scan(value any) error {
if value == nil {
ns.BooksFoo, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.BooksFoo.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullBooksFoo) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.BooksFoo), nil
}
type Author struct {
ID int64
Foo AuthorsFoo
Bar AuthorsBar
Added AuthorsAdded
AddItem AuthorsAddItem
RemoveItem AuthorsRemoveItem
}
type Book struct {
ID int64
Foo BooksFoo
}

View File

@@ -0,0 +1,71 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: query.sql
package querytest
import (
"context"
)
const listAuthors = `-- name: ListAuthors :many
SELECT id, foo, bar, added, add_item, remove_item FROM authors
`
func (q *Queries) ListAuthors(ctx context.Context) ([]Author, error) {
rows, err := q.db.QueryContext(ctx, listAuthors)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Author
for rows.Next() {
var i Author
if err := rows.Scan(
&i.ID,
&i.Foo,
&i.Bar,
&i.Added,
&i.AddItem,
&i.RemoveItem,
); 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 listBooks = `-- name: ListBooks :many
SELECT id, foo FROM books
`
func (q *Queries) ListBooks(ctx context.Context) ([]Book, error) {
rows, err := q.db.QueryContext(ctx, listBooks)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Book
for rows.Next() {
var i Book
if err := rows.Scan(&i.ID, &i.Foo); 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
}

View File

@@ -0,0 +1,5 @@
/* name: ListAuthors :many */
SELECT * FROM authors;
/* name: ListBooks :many */
SELECT * FROM books;

View File

@@ -0,0 +1,39 @@
CREATE TABLE authors (
id BIGINT PRIMARY KEY,
foo ENUM("ok") DEFAULT "ok" NOT NULL,
renamed ENUM("ok") DEFAULT "ok" NOT NULL,
removed ENUM("ok") DEFAULT "ok" NOT NULL,
add_item ENUM("ok") DEFAULT "ok" NOT NULL,
remove_item ENUM("ok", "removed") DEFAULT "ok" NOT NULL
);
CREATE TABLE renamed (
id BIGINT PRIMARY KEY,
foo ENUM("ok") DEFAULT "ok" NOT NULL
);
CREATE TABLE removed (
id BIGINT PRIMARY KEY,
foo ENUM("ok") DEFAULT "ok" NOT NULL
);
/* Rename column */
ALTER TABLE authors RENAME COLUMN renamed TO bar;
/* Drop column */
ALTER TABLE authors DROP COLUMN removed;
/* Add column */
ALTER TABLE authors ADD COLUMN added ENUM("ok") DEFAULT "ok" NOT NULL;
/* Add enum values */
ALTER TABLE authors MODIFY add_item ENUM("ok", "added") DEFAULT "ok" NOT NULL;
/* Remove enum values */
ALTER TABLE authors MODIFY remove_item ENUM("ok") DEFAULT "ok" NOT NULL;
/* Drop table */
DROP TABLE removed;
/* Rename table */
ALTER TABLE renamed RENAME TO books;

View File

@@ -0,0 +1,9 @@
version: "2"
sql:
- engine: "mysql"
schema: "schema.sql"
queries: "query.sql"
gen:
go:
package: "querytest"
out: "go"