complex_params

package
v0.0.0-...-78c55be Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareAllQueries

func PrepareAllQueries(ctx context.Context, p preparer) error

PrepareAllQueries executes a PREPARE statement for all pggen generated SQL queries in querier files. Typical usage is as the AfterConnect callback for pgxpool.Config

pgx will use the prepared statement if available. Calling PrepareAllQueries is an optional optimization to avoid a network round-trip the first time pgx runs a query if pgx statement caching is enabled.

Types

type DBQuerier

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

func NewQuerier

func NewQuerier(conn genericConn) *DBQuerier

NewQuerier creates a DBQuerier that implements Querier. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.

func NewQuerierConfig

func NewQuerierConfig(conn genericConn, cfg QuerierConfig) *DBQuerier

NewQuerierConfig creates a DBQuerier that implements Querier with the given config. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.

func (*DBQuerier) ParamArrayInt

func (q *DBQuerier) ParamArrayInt(ctx context.Context, ints []int) ([]int, error)

ParamArrayInt implements Querier.ParamArrayInt.

func (*DBQuerier) ParamArrayIntBatch

func (q *DBQuerier) ParamArrayIntBatch(batch genericBatch, ints []int)

ParamArrayIntBatch implements Querier.ParamArrayIntBatch.

func (*DBQuerier) ParamArrayIntScan

func (q *DBQuerier) ParamArrayIntScan(results pgx.BatchResults) ([]int, error)

ParamArrayIntScan implements Querier.ParamArrayIntScan.

func (*DBQuerier) ParamNested1

func (q *DBQuerier) ParamNested1(ctx context.Context, dimensions Dimensions) (Dimensions, error)

ParamNested1 implements Querier.ParamNested1.

func (*DBQuerier) ParamNested1Batch

func (q *DBQuerier) ParamNested1Batch(batch genericBatch, dimensions Dimensions)

ParamNested1Batch implements Querier.ParamNested1Batch.

func (*DBQuerier) ParamNested1Scan

func (q *DBQuerier) ParamNested1Scan(results pgx.BatchResults) (Dimensions, error)

ParamNested1Scan implements Querier.ParamNested1Scan.

func (*DBQuerier) ParamNested2

func (q *DBQuerier) ParamNested2(ctx context.Context, image ProductImageType) (ProductImageType, error)

ParamNested2 implements Querier.ParamNested2.

func (*DBQuerier) ParamNested2Array

func (q *DBQuerier) ParamNested2Array(ctx context.Context, images []ProductImageType) ([]ProductImageType, error)

ParamNested2Array implements Querier.ParamNested2Array.

func (*DBQuerier) ParamNested2ArrayBatch

func (q *DBQuerier) ParamNested2ArrayBatch(batch genericBatch, images []ProductImageType)

ParamNested2ArrayBatch implements Querier.ParamNested2ArrayBatch.

func (*DBQuerier) ParamNested2ArrayScan

func (q *DBQuerier) ParamNested2ArrayScan(results pgx.BatchResults) ([]ProductImageType, error)

ParamNested2ArrayScan implements Querier.ParamNested2ArrayScan.

func (*DBQuerier) ParamNested2Batch

func (q *DBQuerier) ParamNested2Batch(batch genericBatch, image ProductImageType)

ParamNested2Batch implements Querier.ParamNested2Batch.

func (*DBQuerier) ParamNested2Scan

func (q *DBQuerier) ParamNested2Scan(results pgx.BatchResults) (ProductImageType, error)

ParamNested2Scan implements Querier.ParamNested2Scan.

func (*DBQuerier) ParamNested3

func (q *DBQuerier) ParamNested3(ctx context.Context, imageSet ProductImageSetType) (ProductImageSetType, error)

ParamNested3 implements Querier.ParamNested3.

func (*DBQuerier) ParamNested3Batch

func (q *DBQuerier) ParamNested3Batch(batch genericBatch, imageSet ProductImageSetType)

ParamNested3Batch implements Querier.ParamNested3Batch.

func (*DBQuerier) ParamNested3Scan

func (q *DBQuerier) ParamNested3Scan(results pgx.BatchResults) (ProductImageSetType, error)

ParamNested3Scan implements Querier.ParamNested3Scan.

func (*DBQuerier) WithTx

func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)

WithTx creates a new DBQuerier that uses the transaction to run all queries.

type Dimensions

type Dimensions struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

Dimensions represents the Postgres composite type "dimensions".

type ProductImageSetType

type ProductImageSetType struct {
	Name      string             `json:"name"`
	OrigImage ProductImageType   `json:"orig_image"`
	Images    []ProductImageType `json:"images"`
}

ProductImageSetType represents the Postgres composite type "product_image_set_type".

type ProductImageType

type ProductImageType struct {
	Source     string     `json:"source"`
	Dimensions Dimensions `json:"dimensions"`
}

ProductImageType represents the Postgres composite type "product_image_type".

type Querier

type Querier interface {
	ParamArrayInt(ctx context.Context, ints []int) ([]int, error)
	// ParamArrayIntBatch enqueues a ParamArrayInt query into batch to be executed
	// later by the batch.
	ParamArrayIntBatch(batch genericBatch, ints []int)
	// ParamArrayIntScan scans the result of an executed ParamArrayIntBatch query.
	ParamArrayIntScan(results pgx.BatchResults) ([]int, error)

	ParamNested1(ctx context.Context, dimensions Dimensions) (Dimensions, error)
	// ParamNested1Batch enqueues a ParamNested1 query into batch to be executed
	// later by the batch.
	ParamNested1Batch(batch genericBatch, dimensions Dimensions)
	// ParamNested1Scan scans the result of an executed ParamNested1Batch query.
	ParamNested1Scan(results pgx.BatchResults) (Dimensions, error)

	ParamNested2(ctx context.Context, image ProductImageType) (ProductImageType, error)
	// ParamNested2Batch enqueues a ParamNested2 query into batch to be executed
	// later by the batch.
	ParamNested2Batch(batch genericBatch, image ProductImageType)
	// ParamNested2Scan scans the result of an executed ParamNested2Batch query.
	ParamNested2Scan(results pgx.BatchResults) (ProductImageType, error)

	ParamNested2Array(ctx context.Context, images []ProductImageType) ([]ProductImageType, error)
	// ParamNested2ArrayBatch enqueues a ParamNested2Array query into batch to be executed
	// later by the batch.
	ParamNested2ArrayBatch(batch genericBatch, images []ProductImageType)
	// ParamNested2ArrayScan scans the result of an executed ParamNested2ArrayBatch query.
	ParamNested2ArrayScan(results pgx.BatchResults) ([]ProductImageType, error)

	ParamNested3(ctx context.Context, imageSet ProductImageSetType) (ProductImageSetType, error)
	// ParamNested3Batch enqueues a ParamNested3 query into batch to be executed
	// later by the batch.
	ParamNested3Batch(batch genericBatch, imageSet ProductImageSetType)
	// ParamNested3Scan scans the result of an executed ParamNested3Batch query.
	ParamNested3Scan(results pgx.BatchResults) (ProductImageSetType, error)
}

Querier is a typesafe Go interface backed by SQL queries.

Methods ending with Batch enqueue a query to run later in a pgx.Batch. After calling SendBatch on pgx.Conn, pgxpool.Pool, or pgx.Tx, use the Scan methods to parse the results.

type QuerierConfig

type QuerierConfig struct {
	// DataTypes contains pgtype.Value to use for encoding and decoding instead
	// of pggen-generated pgtype.ValueTranscoder.
	//
	// If OIDs are available for an input parameter type and all of its
	// transitive dependencies, pggen will use the binary encoding format for
	// the input parameter.
	DataTypes []pgtype.DataType
}

Jump to

Keyboard shortcuts

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