gen

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	And = runtime.And
	Or  = runtime.Or
)

And / Or combine @filter-tree predicates built with the generated per-query constructors.

View Source
var ShapeSpace = map[string]runtime.ShapeSpaceInfo{
	"CountByStatus":   {Enumerable: 1, Exact: true, Unbounded: false},
	"FilterUsers":     {Enumerable: 1, Exact: true, Unbounded: true},
	"FindUserByEmail": {Enumerable: 1, Exact: true, Unbounded: false},
	"SearchUsers":     {Enumerable: 8, Exact: true, Unbounded: false},
	"UsersInStatuses": {Enumerable: 1, Exact: true, Unbounded: true},
}

ShapeSpace describes each query's reachable shape space, computed at generate time (design doc 18): the enumerable dimensions' shape count, whether that count is exact (large @order-by permutation spaces saturate at MaxUint64), and whether unbounded dimensions exist (@filter-tree structure; @in arity on expanding dialects) — under which used-vs-reachable coverage is a floor, never a ratio.

Functions

func FilterUsersEmailPrefix

func FilterUsersEmailPrefix(scopePrefix string) runtime.Tree

FilterUsersEmailPrefix builds the "email_prefix" predicate of @filter-tree(scope).

func FilterUsersStatusEq

func FilterUsersStatusEq(scopeStatus string) runtime.Tree

FilterUsersStatusEq builds the "status_eq" predicate of @filter-tree(scope).

func FilterUsersTenant

func FilterUsersTenant(scopeTenantID int64) runtime.Tree

FilterUsersTenant builds the "tenant" predicate of @filter-tree(scope).

func FilterUsersUnscoped

func FilterUsersUnscoped() runtime.Tree

FilterUsersUnscoped is the explicit, greppable opt-out: it renders TRUE.

Types

type CountByStatusParams

type CountByStatusParams struct {
	TenantID int64
}

type CountByStatusRow

type CountByStatusRow struct {
	Status string
	N      int64
}

type DBTX

type DBTX interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

DBTX matches sqlc's database/sql flavor: a *sql.DB or *sql.Tx satisfies it, so sqlc- and sqletch-generated code share transactions.

type FilterUsersParams

type FilterUsersParams struct {
	Limit int64
}

type FilterUsersRow

type FilterUsersRow struct {
	ID    int64
	Email string
}

type FindUserByEmailParams

type FindUserByEmailParams struct {
	Email string
}

type FindUserByEmailRow

type FindUserByEmailRow struct {
	ID       int64
	Email    string
	Nickname optional.Option[string]
}

type Querier

type Querier interface {
	CountByStatus(ctx context.Context, arg CountByStatusParams) ([]CountByStatusRow, error)
	FilterUsers(ctx context.Context, scope runtime.Tree, arg FilterUsersParams) ([]FilterUsersRow, error)
	FindUserByEmail(ctx context.Context, arg FindUserByEmailParams) (optional.Option[FindUserByEmailRow], error)
	SearchUsers(ctx context.Context, arg SearchUsersParams) ([]SearchUsersRow, error)
	UsersInStatuses(ctx context.Context, arg UsersInStatusesParams) ([]UsersInStatusesRow, error)
}

Querier lets user code mock the generated queries.

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) Cache

func (q *Queries) Cache() *runtime.ComposedCache

Cache exposes the composed-SQL cache for scrape-time inspection (Stats, TopShapes). Mutating it is the generated code's business, not the caller's.

func (*Queries) CountByStatus

func (q *Queries) CountByStatus(ctx context.Context, arg CountByStatusParams) ([]CountByStatusRow, error)

func (*Queries) FilterUsers

func (q *Queries) FilterUsers(ctx context.Context, scope runtime.Tree, arg FilterUsersParams) ([]FilterUsersRow, error)

scope is required (@filter-tree!; FilterUsersUnscoped() opts out).

func (*Queries) FindUserByEmail

func (*Queries) OnQuery

func (q *Queries) OnQuery(fn func(shapeKey, sql string))

OnQuery installs an observability hook receiving the shape key and the composed SQL of every call.

func (*Queries) SearchUsers

func (q *Queries) SearchUsers(ctx context.Context, arg SearchUsersParams) ([]SearchUsersRow, error)

func (*Queries) SetObserver

func (q *Queries) SetObserver(o runtime.Observer)

SetObserver installs a runtime observer receiving compose, exec, and reject events for every query on this Queries value and any WithTx derivative (design doc 18). Install it before serving traffic; Cache() exposes the same cache for scrape-time Stats and TopShapes.

func (*Queries) UsersInStatuses

func (q *Queries) UsersInStatuses(ctx context.Context, arg UsersInStatusesParams) ([]UsersInStatusesRow, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type SearchUsersParams

type SearchUsersParams struct {
	Status      optional.Option[string] // None omits the guarded fragment(s)
	EmailPrefix optional.Option[string] // None omits the guarded fragment(s)
	Limit       int64
	Sort        SearchUsersSort // zero value selects @default
}

type SearchUsersRow

type SearchUsersRow struct {
	ID       int64
	Email    string
	Status   string
	Nickname optional.Option[string]
}

type SearchUsersSort

type SearchUsersSort int
const (
	SearchUsersSortDefault SearchUsersSort = iota
	SearchUsersSortEmailAsc
)

type UsersInStatusesParams

type UsersInStatusesParams struct {
	TenantID int64
	Statuses []string // @in list; empty matches nothing
	Limit    int64
}

type UsersInStatusesRow

type UsersInStatusesRow struct {
	ID     int64
	Email  string
	Status string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL