syntax

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: 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 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 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) Backtick

func (q *DBQuerier) Backtick(ctx context.Context) (string, error)

Backtick implements Querier.Backtick.

func (*DBQuerier) BacktickBackslashN

func (q *DBQuerier) BacktickBackslashN(ctx context.Context) (string, error)

BacktickBackslashN implements Querier.BacktickBackslashN.

func (*DBQuerier) BacktickBackslashNBatch

func (q *DBQuerier) BacktickBackslashNBatch(batch genericBatch)

BacktickBackslashNBatch implements Querier.BacktickBackslashNBatch.

func (*DBQuerier) BacktickBackslashNScan

func (q *DBQuerier) BacktickBackslashNScan(results pgx.BatchResults) (string, error)

BacktickBackslashNScan implements Querier.BacktickBackslashNScan.

func (*DBQuerier) BacktickBatch

func (q *DBQuerier) BacktickBatch(batch genericBatch)

BacktickBatch implements Querier.BacktickBatch.

func (*DBQuerier) BacktickDoubleQuote

func (q *DBQuerier) BacktickDoubleQuote(ctx context.Context) (string, error)

BacktickDoubleQuote implements Querier.BacktickDoubleQuote.

func (*DBQuerier) BacktickDoubleQuoteBatch

func (q *DBQuerier) BacktickDoubleQuoteBatch(batch genericBatch)

BacktickDoubleQuoteBatch implements Querier.BacktickDoubleQuoteBatch.

func (*DBQuerier) BacktickDoubleQuoteScan

func (q *DBQuerier) BacktickDoubleQuoteScan(results pgx.BatchResults) (string, error)

BacktickDoubleQuoteScan implements Querier.BacktickDoubleQuoteScan.

func (*DBQuerier) BacktickNewline

func (q *DBQuerier) BacktickNewline(ctx context.Context) (string, error)

BacktickNewline implements Querier.BacktickNewline.

func (*DBQuerier) BacktickNewlineBatch

func (q *DBQuerier) BacktickNewlineBatch(batch genericBatch)

BacktickNewlineBatch implements Querier.BacktickNewlineBatch.

func (*DBQuerier) BacktickNewlineScan

func (q *DBQuerier) BacktickNewlineScan(results pgx.BatchResults) (string, error)

BacktickNewlineScan implements Querier.BacktickNewlineScan.

func (*DBQuerier) BacktickQuoteBacktick

func (q *DBQuerier) BacktickQuoteBacktick(ctx context.Context) (string, error)

BacktickQuoteBacktick implements Querier.BacktickQuoteBacktick.

func (*DBQuerier) BacktickQuoteBacktickBatch

func (q *DBQuerier) BacktickQuoteBacktickBatch(batch genericBatch)

BacktickQuoteBacktickBatch implements Querier.BacktickQuoteBacktickBatch.

func (*DBQuerier) BacktickQuoteBacktickScan

func (q *DBQuerier) BacktickQuoteBacktickScan(results pgx.BatchResults) (string, error)

BacktickQuoteBacktickScan implements Querier.BacktickQuoteBacktickScan.

func (*DBQuerier) BacktickScan

func (q *DBQuerier) BacktickScan(results pgx.BatchResults) (string, error)

BacktickScan implements Querier.BacktickScan.

func (*DBQuerier) BadEnumName

func (q *DBQuerier) BadEnumName(ctx context.Context) (UnnamedEnum123, error)

BadEnumName implements Querier.BadEnumName.

func (*DBQuerier) BadEnumNameBatch

func (q *DBQuerier) BadEnumNameBatch(batch genericBatch)

BadEnumNameBatch implements Querier.BadEnumNameBatch.

func (*DBQuerier) BadEnumNameScan

func (q *DBQuerier) BadEnumNameScan(results pgx.BatchResults) (UnnamedEnum123, error)

BadEnumNameScan implements Querier.BadEnumNameScan.

func (*DBQuerier) GoKeyword

func (q *DBQuerier) GoKeyword(ctx context.Context, go_ string) (string, error)

GoKeyword implements Querier.GoKeyword.

func (*DBQuerier) GoKeywordBatch

func (q *DBQuerier) GoKeywordBatch(batch genericBatch, go_ string)

GoKeywordBatch implements Querier.GoKeywordBatch.

func (*DBQuerier) GoKeywordScan

func (q *DBQuerier) GoKeywordScan(results pgx.BatchResults) (string, error)

GoKeywordScan implements Querier.GoKeywordScan.

func (*DBQuerier) IllegalNameSymbols

func (q *DBQuerier) IllegalNameSymbols(ctx context.Context, helloWorld string) (IllegalNameSymbolsRow, error)

IllegalNameSymbols implements Querier.IllegalNameSymbols.

func (*DBQuerier) IllegalNameSymbolsBatch

func (q *DBQuerier) IllegalNameSymbolsBatch(batch genericBatch, helloWorld string)

IllegalNameSymbolsBatch implements Querier.IllegalNameSymbolsBatch.

func (*DBQuerier) IllegalNameSymbolsScan

func (q *DBQuerier) IllegalNameSymbolsScan(results pgx.BatchResults) (IllegalNameSymbolsRow, error)

IllegalNameSymbolsScan implements Querier.IllegalNameSymbolsScan.

func (*DBQuerier) SpaceAfter

func (q *DBQuerier) SpaceAfter(ctx context.Context, space string) (string, error)

SpaceAfter implements Querier.SpaceAfter.

func (*DBQuerier) SpaceAfterBatch

func (q *DBQuerier) SpaceAfterBatch(batch genericBatch, space string)

SpaceAfterBatch implements Querier.SpaceAfterBatch.

func (*DBQuerier) SpaceAfterScan

func (q *DBQuerier) SpaceAfterScan(results pgx.BatchResults) (string, error)

SpaceAfterScan implements Querier.SpaceAfterScan.

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 IllegalNameSymbolsRow

type IllegalNameSymbolsRow struct {
	UnnamedColumn0 string `json:"$"`
	FooBar         string `json:"foo.bar!@#$%&*()\"--+"`
}

type Querier

type Querier interface {
	// Query to test escaping in generated Go.
	Backtick(ctx context.Context) (string, error)
	// BacktickBatch enqueues a Backtick query into batch to be executed
	// later by the batch.
	BacktickBatch(batch genericBatch)
	// BacktickScan scans the result of an executed BacktickBatch query.
	BacktickScan(results pgx.BatchResults) (string, error)

	// Query to test escaping in generated Go.
	BacktickQuoteBacktick(ctx context.Context) (string, error)
	// BacktickQuoteBacktickBatch enqueues a BacktickQuoteBacktick query into batch to be executed
	// later by the batch.
	BacktickQuoteBacktickBatch(batch genericBatch)
	// BacktickQuoteBacktickScan scans the result of an executed BacktickQuoteBacktickBatch query.
	BacktickQuoteBacktickScan(results pgx.BatchResults) (string, error)

	// Query to test escaping in generated Go.
	BacktickNewline(ctx context.Context) (string, error)
	// BacktickNewlineBatch enqueues a BacktickNewline query into batch to be executed
	// later by the batch.
	BacktickNewlineBatch(batch genericBatch)
	// BacktickNewlineScan scans the result of an executed BacktickNewlineBatch query.
	BacktickNewlineScan(results pgx.BatchResults) (string, error)

	// Query to test escaping in generated Go.
	BacktickDoubleQuote(ctx context.Context) (string, error)
	// BacktickDoubleQuoteBatch enqueues a BacktickDoubleQuote query into batch to be executed
	// later by the batch.
	BacktickDoubleQuoteBatch(batch genericBatch)
	// BacktickDoubleQuoteScan scans the result of an executed BacktickDoubleQuoteBatch query.
	BacktickDoubleQuoteScan(results pgx.BatchResults) (string, error)

	// Query to test escaping in generated Go.
	BacktickBackslashN(ctx context.Context) (string, error)
	// BacktickBackslashNBatch enqueues a BacktickBackslashN query into batch to be executed
	// later by the batch.
	BacktickBackslashNBatch(batch genericBatch)
	// BacktickBackslashNScan scans the result of an executed BacktickBackslashNBatch query.
	BacktickBackslashNScan(results pgx.BatchResults) (string, error)

	// Illegal names.
	IllegalNameSymbols(ctx context.Context, helloWorld string) (IllegalNameSymbolsRow, error)
	// IllegalNameSymbolsBatch enqueues a IllegalNameSymbols query into batch to be executed
	// later by the batch.
	IllegalNameSymbolsBatch(batch genericBatch, helloWorld string)
	// IllegalNameSymbolsScan scans the result of an executed IllegalNameSymbolsBatch query.
	IllegalNameSymbolsScan(results pgx.BatchResults) (IllegalNameSymbolsRow, error)

	// Space after sqlgen.required_arg
	SpaceAfter(ctx context.Context, space string) (string, error)
	// SpaceAfterBatch enqueues a SpaceAfter query into batch to be executed
	// later by the batch.
	SpaceAfterBatch(batch genericBatch, space string)
	// SpaceAfterScan scans the result of an executed SpaceAfterBatch query.
	SpaceAfterScan(results pgx.BatchResults) (string, error)

	// Enum named 123.
	BadEnumName(ctx context.Context) (UnnamedEnum123, error)
	// BadEnumNameBatch enqueues a BadEnumName query into batch to be executed
	// later by the batch.
	BadEnumNameBatch(batch genericBatch)
	// BadEnumNameScan scans the result of an executed BadEnumNameBatch query.
	BadEnumNameScan(results pgx.BatchResults) (UnnamedEnum123, error)

	GoKeyword(ctx context.Context, go_ string) (string, error)
	// GoKeywordBatch enqueues a GoKeyword query into batch to be executed
	// later by the batch.
	GoKeywordBatch(batch genericBatch, go_ string)
	// GoKeywordScan scans the result of an executed GoKeywordBatch query.
	GoKeywordScan(results pgx.BatchResults) (string, 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
}

type UnnamedEnum123

type UnnamedEnum123 string

UnnamedEnum123 represents the Postgres enum "123".

const (
	UnnamedEnum123InconvertibleEnumName UnnamedEnum123 = "inconvertible_enum_name"
	UnnamedEnum123UnnamedLabel1         UnnamedEnum123 = ""
	UnnamedEnum123UnnamedLabel2111      UnnamedEnum123 = "111"
	UnnamedEnum123UnnamedLabel3         UnnamedEnum123 = "!!"
)

func (UnnamedEnum123) String

func (u UnnamedEnum123) String() string

Jump to

Keyboard shortcuts

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