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

3
examples/jets/README.md Normal file
View File

@@ -0,0 +1,3 @@
This database schema and query selection is taken from the
[SQLBoiler](https://github.com/volatiletech/sqlboiler#features--examples)
README.

View File

@@ -0,0 +1,32 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package jets
import (
"context"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
)
type DBTX interface {
Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
Query(context.Context, string, ...any) (pgx.Rows, error)
QueryRow(context.Context, string, ...any) pgx.Row
}
func New(db DBTX) *Queries {
return &Queries{db: db}
}
type Queries struct {
db DBTX
}
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
return &Queries{
db: tx,
}
}

View File

@@ -0,0 +1,28 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package jets
type Jet struct {
ID int32
PilotID int32
Age int32
Name string
Color string
}
type Language struct {
ID int32
Language string
}
type Pilot struct {
ID int32
Name string
}
type PilotLanguage struct {
PilotID int32
LanguageID int32
}

View File

@@ -0,0 +1,8 @@
-- name: CountPilots :one
SELECT COUNT(*) FROM pilots;
-- name: ListPilots :many
SELECT * FROM pilots LIMIT 5;
-- name: DeletePilot :exec
DELETE FROM pilots WHERE id = $1;

View File

@@ -0,0 +1,54 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: query-building.sql
package jets
import (
"context"
)
const countPilots = `-- name: CountPilots :one
SELECT COUNT(*) FROM pilots
`
func (q *Queries) CountPilots(ctx context.Context) (int64, error) {
row := q.db.QueryRow(ctx, countPilots)
var count int64
err := row.Scan(&count)
return count, err
}
const deletePilot = `-- name: DeletePilot :exec
DELETE FROM pilots WHERE id = $1
`
func (q *Queries) DeletePilot(ctx context.Context, id int32) error {
_, err := q.db.Exec(ctx, deletePilot, id)
return err
}
const listPilots = `-- name: ListPilots :many
SELECT id, name FROM pilots LIMIT 5
`
func (q *Queries) ListPilots(ctx context.Context) ([]Pilot, error) {
rows, err := q.db.Query(ctx, listPilots)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Pilot
for rows.Next() {
var i Pilot
if err := rows.Scan(&i.ID, &i.Name); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}

View File

@@ -0,0 +1,35 @@
CREATE TABLE pilots (
id integer NOT NULL,
name text NOT NULL
);
ALTER TABLE pilots ADD CONSTRAINT pilot_pkey PRIMARY KEY (id);
CREATE TABLE jets (
id integer NOT NULL,
pilot_id integer NOT NULL,
age integer NOT NULL,
name text NOT NULL,
color text NOT NULL
);
ALTER TABLE jets ADD CONSTRAINT jet_pkey PRIMARY KEY (id);
ALTER TABLE jets ADD CONSTRAINT jet_pilots_fkey FOREIGN KEY (pilot_id) REFERENCES pilots(id);
CREATE TABLE languages (
id integer NOT NULL,
language text NOT NULL
);
ALTER TABLE languages ADD CONSTRAINT language_pkey PRIMARY KEY (id);
-- Join table
CREATE TABLE pilot_languages (
pilot_id integer NOT NULL,
language_id integer NOT NULL
);
-- Composite primary key
ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_pkey PRIMARY KEY (pilot_id, language_id);
ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_pilots_fkey FOREIGN KEY (pilot_id) REFERENCES pilots(id);
ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_languages_fkey FOREIGN KEY (language_id) REFERENCES languages(id);

25
examples/jets/sqlc.json Normal file
View File

@@ -0,0 +1,25 @@
{
"version": "1",
"cloud": {
"project": "01HAQMMECEYQYKFJN8MP16QC41"
},
"packages": [
{
"path": "postgresql",
"name": "jets",
"schema": "postgresql/schema.sql",
"queries": "postgresql/query-building.sql",
"engine": "postgresql",
"sql_package": "pgx/v5",
"database": {
"uri": "${VET_TEST_EXAMPLES_POSTGRES_JETS}"
},
"analyzer": {
"database": false
},
"rules": [
"sqlc/db-prepare"
]
}
]
}