custom_types

package
v0.0.0-...-1a642c0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 6 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 sqlgen 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 CustomInt

type CustomInt int

CustomInt is a custom type in the same package as the query file.

type CustomTypesRow

type CustomTypesRow struct {
	Column mytype.String `json:"?column?"`
	Int8   CustomInt     `json:"int8"`
}

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) CustomMyInt

func (q *DBQuerier) CustomMyInt(ctx context.Context) (int, error)

CustomMyInt implements Querier.CustomMyInt.

func (*DBQuerier) CustomMyIntBatch

func (q *DBQuerier) CustomMyIntBatch(batch genericBatch)

CustomMyIntBatch implements Querier.CustomMyIntBatch.

func (*DBQuerier) CustomMyIntScan

func (q *DBQuerier) CustomMyIntScan(results pgx.BatchResults) (int, error)

CustomMyIntScan implements Querier.CustomMyIntScan.

func (*DBQuerier) CustomTypes

func (q *DBQuerier) CustomTypes(ctx context.Context) (CustomTypesRow, error)

CustomTypes implements Querier.CustomTypes.

func (*DBQuerier) CustomTypesBatch

func (q *DBQuerier) CustomTypesBatch(batch genericBatch)

CustomTypesBatch implements Querier.CustomTypesBatch.

func (*DBQuerier) CustomTypesScan

func (q *DBQuerier) CustomTypesScan(results pgx.BatchResults) (CustomTypesRow, error)

CustomTypesScan implements Querier.CustomTypesScan.

func (*DBQuerier) IntArray

func (q *DBQuerier) IntArray(ctx context.Context) ([][]int32, error)

IntArray implements Querier.IntArray.

func (*DBQuerier) IntArrayBatch

func (q *DBQuerier) IntArrayBatch(batch genericBatch)

IntArrayBatch implements Querier.IntArrayBatch.

func (*DBQuerier) IntArrayScan

func (q *DBQuerier) IntArrayScan(results pgx.BatchResults) ([][]int32, error)

IntArrayScan implements Querier.IntArrayScan.

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 Querier

type Querier interface {
	CustomTypes(ctx context.Context) (CustomTypesRow, error)
	// CustomTypesBatch enqueues a CustomTypes query into batch to be executed
	// later by the batch.
	CustomTypesBatch(batch genericBatch)
	// CustomTypesScan scans the result of an executed CustomTypesBatch query.
	CustomTypesScan(results pgx.BatchResults) (CustomTypesRow, error)

	CustomMyInt(ctx context.Context) (int, error)
	// CustomMyIntBatch enqueues a CustomMyInt query into batch to be executed
	// later by the batch.
	CustomMyIntBatch(batch genericBatch)
	// CustomMyIntScan scans the result of an executed CustomMyIntBatch query.
	CustomMyIntScan(results pgx.BatchResults) (int, error)

	IntArray(ctx context.Context) ([][]int32, error)
	// IntArrayBatch enqueues a IntArray query into batch to be executed
	// later by the batch.
	IntArrayBatch(batch genericBatch)
	// IntArrayScan scans the result of an executed IntArrayBatch query.
	IntArrayScan(results pgx.BatchResults) ([][]int32, 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 sqlgen-generated pgtype.ValueTranscoder.
	//
	// If OIDs are available for an input parameter type and all of its
	// transitive dependencies, sqlgen will use the binary encoding format for
	// the input parameter.
	DataTypes []pgtype.DataType
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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