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/pg_dump/db/db.go
vendored
Normal file
31
internal/endtoend/testdata/pg_dump/db/db.go
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package db
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
15
internal/endtoend/testdata/pg_dump/db/models.go
vendored
Normal file
15
internal/endtoend/testdata/pg_dump/db/models.go
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type Author struct {
|
||||
ID int64
|
||||
Name string
|
||||
Bio sql.NullString
|
||||
}
|
||||
82
internal/endtoend/testdata/pg_dump/db/query.sql.go
vendored
Normal file
82
internal/endtoend/testdata/pg_dump/db/query.sql.go
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: query.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const createAuthor = `-- name: CreateAuthor :one
|
||||
INSERT INTO authors (
|
||||
name, bio
|
||||
) VALUES (
|
||||
$1, $2
|
||||
)
|
||||
RETURNING id, name, bio
|
||||
`
|
||||
|
||||
type CreateAuthorParams struct {
|
||||
Name string
|
||||
Bio sql.NullString
|
||||
}
|
||||
|
||||
func (q *Queries) CreateAuthor(ctx context.Context, arg CreateAuthorParams) (Author, error) {
|
||||
row := q.db.QueryRowContext(ctx, createAuthor, arg.Name, arg.Bio)
|
||||
var i Author
|
||||
err := row.Scan(&i.ID, &i.Name, &i.Bio)
|
||||
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
|
||||
`
|
||||
|
||||
func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) {
|
||||
row := q.db.QueryRowContext(ctx, getAuthor, id)
|
||||
var i Author
|
||||
err := row.Scan(&i.ID, &i.Name, &i.Bio)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listAuthors = `-- name: ListAuthors :many
|
||||
SELECT id, name, bio FROM authors
|
||||
ORDER BY name
|
||||
`
|
||||
|
||||
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.Name, &i.Bio); 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
|
||||
}
|
||||
6
internal/endtoend/testdata/pg_dump/exec.json
vendored
Normal file
6
internal/endtoend/testdata/pg_dump/exec.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"contexts": ["base"],
|
||||
"meta": {
|
||||
"invalid_schema": true
|
||||
}
|
||||
}
|
||||
19
internal/endtoend/testdata/pg_dump/query.sql
vendored
Normal file
19
internal/endtoend/testdata/pg_dump/query.sql
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
-- name: GetAuthor :one
|
||||
SELECT * FROM authors
|
||||
WHERE id = $1 LIMIT 1;
|
||||
|
||||
-- name: ListAuthors :many
|
||||
SELECT * FROM authors
|
||||
ORDER BY name;
|
||||
|
||||
-- name: CreateAuthor :one
|
||||
INSERT INTO authors (
|
||||
name, bio
|
||||
) VALUES (
|
||||
$1, $2
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteAuthor :exec
|
||||
DELETE FROM authors
|
||||
WHERE id = $1;
|
||||
93
internal/endtoend/testdata/pg_dump/schema.sql
vendored
Normal file
93
internal/endtoend/testdata/pg_dump/schema.sql
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 15.3 (Debian 15.3-1.pgdg120+1)
|
||||
-- Dumped by pg_dump version 15.3
|
||||
|
||||
\restrict auwherpfqaiuwrhgp
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- Name: public; Type: SCHEMA; Schema: -; Owner: pg_database_owner
|
||||
--
|
||||
|
||||
CREATE SCHEMA public;
|
||||
|
||||
|
||||
ALTER SCHEMA public OWNER TO pg_database_owner;
|
||||
|
||||
--
|
||||
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: pg_database_owner
|
||||
--
|
||||
|
||||
COMMENT ON SCHEMA public IS 'standard public schema';
|
||||
|
||||
|
||||
SET default_table_access_method = heap;
|
||||
|
||||
--
|
||||
-- Name: authors; Type: TABLE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE public.authors (
|
||||
id bigint NOT NULL,
|
||||
name text NOT NULL,
|
||||
bio text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.authors OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: authors_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.authors_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER TABLE public.authors_id_seq OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: authors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.authors_id_seq OWNED BY public.authors.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: authors id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.authors ALTER COLUMN id SET DEFAULT nextval('public.authors_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: authors authors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.authors
|
||||
ADD CONSTRAINT authors_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
\unrestrict auwherpfqaiuwrhgp
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
12
internal/endtoend/testdata/pg_dump/sqlc.json
vendored
Normal file
12
internal/endtoend/testdata/pg_dump/sqlc.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": "1",
|
||||
"packages": [
|
||||
{
|
||||
"path": "db",
|
||||
"engine": "postgresql",
|
||||
"schema": "schema.sql",
|
||||
"queries": "query.sql"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user