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/query_parameter_limit_to_two/postgresql/go/db.go
vendored
Normal file
31
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/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,
|
||||
}
|
||||
}
|
||||
22
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/go/models.go
vendored
Normal file
22
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/go/models.go
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type Author struct {
|
||||
ID int64
|
||||
Name string
|
||||
Bio sql.NullString
|
||||
CountryCode string
|
||||
Titles []string
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
ID int32
|
||||
Name string
|
||||
}
|
||||
164
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/go/query.sql.go
vendored
Normal file
164
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/go/query.sql.go
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: query.sql
|
||||
|
||||
package querytest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"strings"
|
||||
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
const addNewClient = `-- name: AddNewClient :one
|
||||
INSERT INTO clients (
|
||||
id, name
|
||||
) VALUES (
|
||||
$1, $2
|
||||
)
|
||||
RETURNING id, name
|
||||
`
|
||||
|
||||
func (q *Queries) AddNewClient(ctx context.Context, iD int32, name string) (Client, error) {
|
||||
row := q.db.QueryRowContext(ctx, addNewClient, iD, name)
|
||||
var i Client
|
||||
err := row.Scan(&i.ID, &i.Name)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createAuthor = `-- name: CreateAuthor :one
|
||||
INSERT INTO authors (
|
||||
name, bio, country_code, titles
|
||||
) VALUES (
|
||||
$1, $2, $3, $4
|
||||
)
|
||||
RETURNING id, name, bio, country_code, titles
|
||||
`
|
||||
|
||||
type CreateAuthorParams struct {
|
||||
Name string
|
||||
Bio sql.NullString
|
||||
CountryCode string
|
||||
Titles []string
|
||||
}
|
||||
|
||||
func (q *Queries) CreateAuthor(ctx context.Context, arg CreateAuthorParams) (Author, error) {
|
||||
row := q.db.QueryRowContext(ctx, createAuthor,
|
||||
arg.Name,
|
||||
arg.Bio,
|
||||
arg.CountryCode,
|
||||
pq.Array(arg.Titles),
|
||||
)
|
||||
var i Author
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Bio,
|
||||
&i.CountryCode,
|
||||
pq.Array(&i.Titles),
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createAuthorOnlyTitles = `-- name: CreateAuthorOnlyTitles :one
|
||||
INSERT INTO authors (name, titles) VALUES ($1, $2) RETURNING id, name, bio, country_code, titles
|
||||
`
|
||||
|
||||
func (q *Queries) CreateAuthorOnlyTitles(ctx context.Context, name string, titles []string) (Author, error) {
|
||||
row := q.db.QueryRowContext(ctx, createAuthorOnlyTitles, name, pq.Array(titles))
|
||||
var i Author
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Bio,
|
||||
&i.CountryCode,
|
||||
pq.Array(&i.Titles),
|
||||
)
|
||||
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 deleteAuthors = `-- name: DeleteAuthors :exec
|
||||
DELETE FROM authors
|
||||
WHERE id IN ($2) AND name = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteAuthors(ctx context.Context, name string, ids []int64) error {
|
||||
query := deleteAuthors
|
||||
var queryParams []any
|
||||
queryParams = append(queryParams, name)
|
||||
if len(ids) > 0 {
|
||||
for _, v := range ids {
|
||||
queryParams = append(queryParams, v)
|
||||
}
|
||||
query = strings.Replace(query, "/*SLICE:ids*/?", strings.Repeat(",?", len(ids))[1:], 1)
|
||||
} else {
|
||||
query = strings.Replace(query, "/*SLICE:ids*/?", "NULL", 1)
|
||||
}
|
||||
_, err := q.db.ExecContext(ctx, query, queryParams...)
|
||||
return err
|
||||
}
|
||||
|
||||
const getAuthor = `-- name: GetAuthor :one
|
||||
SELECT id, name, bio, country_code, titles FROM authors
|
||||
WHERE name = $1 AND country_code = $2 LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAuthor(ctx context.Context, name string, countryCode string) (Author, error) {
|
||||
row := q.db.QueryRowContext(ctx, getAuthor, name, countryCode)
|
||||
var i Author
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Bio,
|
||||
&i.CountryCode,
|
||||
pq.Array(&i.Titles),
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listAuthors = `-- name: ListAuthors :many
|
||||
SELECT id, name, bio, country_code, titles 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,
|
||||
&i.CountryCode,
|
||||
pq.Array(&i.Titles),
|
||||
); 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
|
||||
}
|
||||
34
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/query.sql
vendored
Normal file
34
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/query.sql
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
-- name: GetAuthor :one
|
||||
SELECT * FROM authors
|
||||
WHERE name = $1 AND country_code = $2 LIMIT 1;
|
||||
|
||||
-- name: ListAuthors :many
|
||||
SELECT * FROM authors
|
||||
ORDER BY name;
|
||||
|
||||
-- name: CreateAuthor :one
|
||||
INSERT INTO authors (
|
||||
name, bio, country_code, titles
|
||||
) VALUES (
|
||||
$1, $2, $3, $4
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteAuthor :exec
|
||||
DELETE FROM authors
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: DeleteAuthors :exec
|
||||
DELETE FROM authors
|
||||
WHERE id IN (sqlc.slice(ids)) AND name = $1;
|
||||
|
||||
-- name: CreateAuthorOnlyTitles :one
|
||||
INSERT INTO authors (name, titles) VALUES ($1, $2) RETURNING *;
|
||||
|
||||
-- name: AddNewClient :one
|
||||
INSERT INTO clients (
|
||||
id, name
|
||||
) VALUES (
|
||||
$1, $2
|
||||
)
|
||||
RETURNING *;
|
||||
13
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/schema.sql
vendored
Normal file
13
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/schema.sql
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
-- Example queries for sqlc
|
||||
CREATE TABLE authors (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
bio text,
|
||||
country_code CHAR(2) NOT NULL,
|
||||
titles TEXT[]
|
||||
);
|
||||
|
||||
CREATE TABLE clients (
|
||||
id INT PRIMARY KEY,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
14
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/sqlc.json
vendored
Normal file
14
internal/endtoend/testdata/query_parameter_limit_to_two/postgresql/sqlc.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": "1",
|
||||
"packages": [
|
||||
{
|
||||
"path": "go",
|
||||
"engine": "postgresql",
|
||||
"name": "querytest",
|
||||
"schema": "schema.sql",
|
||||
"queries": "query.sql",
|
||||
"query_parameter_limit": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user