queries

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 2 Imported by: 0

README

Expected workflow

  1. Add a SQL query/statement in queries.sql, following the other examples.
  2. Run make sqlc using the same version of sqlc as in build/Dockerfile.codegen

sqlc decides what the return-type of the generated method should be based on the :exec suffix (documentation here):

  • :exec will only tell you whether the query succeeded: error
  • :execrows will tell you how many rows were affected: (int64, error)
  • :one will give you back a single struct: (Author, error)
  • :many will give you back a slice of structs: ([]Author, error)

It is configured by the sqlc.yaml file. You can read docs about the various options it supports here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type GetCheckConstraintsRow

type GetCheckConstraintsRow struct {
	Oid              interface{}
	Name             string
	TableName        string
	Expression       string
	IsValid          bool
	IsNotInheritable bool
}

type GetColumnsForTableRow

type GetColumnsForTableRow struct {
	ColumnName          string
	ColumnType          string
	CollationName       string
	CollationSchemaName string
	DefaultValue        string
	IsNotNull           bool
	ColumnSize          int16
}

type GetDependsOnFunctionsParams added in v0.2.0

type GetDependsOnFunctionsParams struct {
	SystemCatalog interface{}
	ObjectID      interface{}
}

type GetDependsOnFunctionsRow

type GetDependsOnFunctionsRow struct {
	FuncName              string
	FuncIdentityArguments string
	FuncSchemaName        string
}

type GetFunctionsRow

type GetFunctionsRow struct {
	Oid                   interface{}
	FuncName              string
	FuncIdentityArguments string
	FuncSchemaName        string
	FuncDef               string
	FuncLang              string
}

type GetIndexesRow

type GetIndexesRow struct {
	Oid                   interface{}
	IndexName             string
	TableName             string
	DefStmt               string
	ConstraintName        string
	IndexIsValid          bool
	IndexIsPk             bool
	IndexIsUnique         bool
	ParentIndexName       string
	ParentIndexSchemaName string
}

type GetSequencesRow added in v0.2.0

type GetSequencesRow struct {
	SequenceName       string
	SequenceSchemaName string
	OwnerColumnName    string
	OwnerSchemaName    string
	OwnerTableName     string
	Type               string
	StartValue         int64
	Increment          int64
	MaxValue           int64
	MinValue           int64
	CacheSize          int64
	Cycle              bool
}

type GetTablesRow

type GetTablesRow struct {
	Oid                   interface{}
	TableName             string
	ParentTableName       string
	ParentTableSchemaName string
	PartitionKeyDef       string
	PartitionForValues    string
}

type GetTriggersRow

type GetTriggersRow struct {
	TriggerName           string
	OwningTableName       string
	OwningTableSchemaName string
	FuncName              string
	FuncIdentityArguments string
	FuncSchemaName        string
	TriggerDef            string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) GetCheckConstraints

func (q *Queries) GetCheckConstraints(ctx context.Context) ([]GetCheckConstraintsRow, error)

func (*Queries) GetColumnsForIndex

func (q *Queries) GetColumnsForIndex(ctx context.Context, attrelid interface{}) ([]string, error)

func (*Queries) GetColumnsForTable

func (q *Queries) GetColumnsForTable(ctx context.Context, attrelid interface{}) ([]GetColumnsForTableRow, error)

func (*Queries) GetDependsOnFunctions

func (q *Queries) GetDependsOnFunctions(ctx context.Context, arg GetDependsOnFunctionsParams) ([]GetDependsOnFunctionsRow, error)

func (*Queries) GetFunctions

func (q *Queries) GetFunctions(ctx context.Context) ([]GetFunctionsRow, error)

func (*Queries) GetIndexes

func (q *Queries) GetIndexes(ctx context.Context) ([]GetIndexesRow, error)

func (*Queries) GetSequences added in v0.2.0

func (q *Queries) GetSequences(ctx context.Context) ([]GetSequencesRow, error)

func (*Queries) GetTables

func (q *Queries) GetTables(ctx context.Context) ([]GetTablesRow, error)

func (*Queries) GetTriggers

func (q *Queries) GetTriggers(ctx context.Context) ([]GetTriggersRow, error)

func (*Queries) WithTx

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

Jump to

Keyboard shortcuts

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