Help us shape the future of Go! Take the 2026 Go Developer Survey

metadata

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryFlagFilter = "@filter"
	QueryFlagOrder  = "@order"
)
View Source
const (
	CmdExec       = ":exec"
	CmdExecResult = ":execresult"
	CmdExecRows   = ":execrows"
	CmdExecLastId = ":execlastid"
	CmdMany       = ":many"
	CmdOne        = ":one"
	CmdCopyFrom   = ":copyfrom"
	CmdBatchExec  = ":batchexec"
	CmdBatchMany  = ":batchmany"
	CmdBatchOne   = ":batchone"
)

Variables

This section is empty.

Functions

func IsBuilderAnnotation added in v0.3.0

func IsBuilderAnnotation(comment string) bool

IsBuilderAnnotation reports whether a comment line is a builder flag.

func ParseBuilderAnnotations added in v0.3.0

func ParseBuilderAnnotations(comments []string) ([]Filter, []Order, error)

ParseBuilderAnnotations reads @filter / @order comments. Other comments are ignored.

func ParseCommentFlags

func ParseCommentFlags(comments []string) (map[string]string, map[string]bool, map[string]struct{}, error)

ParseCommentFlags processes the comments provided with queries to determine the metadata params, flags and rules to skip. All flags in query comments are prefixed with `@`, e.g. @param, @@sqlc-vet-disable.

func ParseQueryNameAndType

func ParseQueryNameAndType(t string, commentStyle CommentSyntax) (string, string, error)

Types

type CommentSyntax

type CommentSyntax source.CommentSyntax

type Filter added in v0.3.0

type Filter struct {
	Column    string
	Operators []FilterOp
}

Filter is one column and the operators the generated builder may apply.

type FilterOp added in v0.3.0

type FilterOp string

FilterOp is a v1 whitelist of optional AND predicates.

const (
	FilterEq   FilterOp = "eq"
	FilterLike FilterOp = "like"
	FilterGte  FilterOp = "gte"
	FilterLte  FilterOp = "lte"
)

func (FilterOp) MethodSuffix added in v0.3.0

func (op FilterOp) MethodSuffix() string

func (FilterOp) SQL added in v0.3.0

func (op FilterOp) SQL() string

type Metadata

type Metadata struct {
	Name     string
	Cmd      string
	Comments []string
	Params   map[string]string
	Flags    map[string]bool

	// RuleSkiplist contains the names of rules to disable vetting for.
	// If the map is empty, but the disable vet flag is specified, then all rules are ignored.
	RuleSkiplist map[string]struct{}

	Filename string

	// Filters and Orders come from @filter / @order comments on :many queries.
	Filters []Filter
	Orders  []Order
}

type Order added in v0.3.0

type Order struct {
	Column string
}

Order is one column the generated builder may sort by.

Jump to

Keyboard shortcuts

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