queries

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: MIT Imports: 3 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{}
	ConstraintName       string
	ColumnNames          []string
	TableName            string
	TableSchemaName      string
	IsValid              bool
	IsNotInheritable     bool
	ConstraintExpression string
}

type GetColumnsForTableRow

type GetColumnsForTableRow struct {
	ColumnName          string
	CollationName       string
	CollationSchemaName string
	DefaultValue        string
	IsNotNull           bool
	ColumnSize          int16
	IdentityType        string
	StartValue          sql.NullInt64
	IncrementValue      sql.NullInt64
	MaxValue            sql.NullInt64
	MinValue            sql.NullInt64
	CacheSize           sql.NullInt64
	IsCycle             sql.NullBool
	ColumnType          string
}

type GetDependsOnFunctionsParams added in v0.2.0

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

type GetDependsOnFunctionsRow

type GetDependsOnFunctionsRow struct {
	FuncName              string
	FuncSchemaName        string
	FuncIdentityArguments string
}

type GetEnumsRow added in v0.7.0

type GetEnumsRow struct {
	EnumName       string
	EnumSchemaName string
	EnumLabels     []string
}

type GetExtensionsRow added in v0.3.0

type GetExtensionsRow struct {
	Oid              interface{}
	ExtensionName    string
	ExtensionVersion string
	SchemaName       string
}

type GetForeignKeyConstraintsRow added in v0.3.0

type GetForeignKeyConstraintsRow struct {
	ConstraintName         string
	OwningTableName        string
	OwningTableSchemaName  string
	ForeignTableName       string
	ForeignTableSchemaName string
	IsValid                bool
	ConstraintDef          string
}

type GetIndexesRow

type GetIndexesRow struct {
	Oid                   interface{}
	IndexName             string
	TableName             string
	TableSchemaName       string
	DefStmt               string
	ConstraintName        string
	ConstraintType        string
	ConstraintDef         string
	IndexIsValid          bool
	IndexIsPk             bool
	IndexIsUnique         bool
	ParentIndexName       string
	ParentIndexSchemaName string
	ColumnNames           []string
	ConstraintIsLocal     bool
}

type GetPoliciesRow added in v0.7.0

type GetPoliciesRow struct {
	PolicyName            string
	OwningTableName       string
	OwningTableSchemaName string
	IsPermissive          bool
	AppliesTo             []string
	Cmd                   string
	CheckExpression       string
	UsingExpression       string
	ColumnNames           []string
}

type GetProcsRow added in v0.9.0

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

type GetSequencesRow added in v0.2.0

type GetSequencesRow struct {
	SequenceName       string
	SequenceSchemaName string
	OwnerColumnName    string
	OwnerSchemaName    string
	OwnerTableName     string
	StartValue         int64
	IncrementValue     int64
	MaxValue           int64
	MinValue           int64
	CacheSize          int64
	IsCycle            bool
	DataType           string
}

type GetTablesRow

type GetTablesRow struct {
	Oid                   interface{}
	TableName             string
	TableSchemaName       string
	ReplicaIdentity       string
	RlsEnabled            bool
	RlsForced             bool
	ParentTableName       string
	ParentTableSchemaName string
	PartitionKeyDef       string
	PartitionForValues    string
}

type GetTriggersRow

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

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) 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) GetEnums added in v0.7.0

func (q *Queries) GetEnums(ctx context.Context) ([]GetEnumsRow, error)

func (*Queries) GetExtensions added in v0.3.0

func (q *Queries) GetExtensions(ctx context.Context) ([]GetExtensionsRow, error)

func (*Queries) GetForeignKeyConstraints added in v0.3.0

func (q *Queries) GetForeignKeyConstraints(ctx context.Context) ([]GetForeignKeyConstraintsRow, error)

func (*Queries) GetIndexes

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

func (*Queries) GetPolicies added in v0.7.0

func (q *Queries) GetPolicies(ctx context.Context) ([]GetPoliciesRow, error)

func (*Queries) GetProcs added in v0.9.0

func (q *Queries) GetProcs(ctx context.Context, prokind interface{}) ([]GetProcsRow, error)

func (*Queries) GetSchemas added in v0.6.0

func (q *Queries) GetSchemas(ctx context.Context) ([]string, 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