Documentation
¶
Overview ¶
sqlc as a std/parsec consumer.
sqlc's *main* SQL parsing uses ANTLR/pg_query, but its small query-annotation grammar — `-- name: <QueryName> :<cmd>` — is a genuine parsing task. A query name is a Go identifier and a command is one of a fixed keyword set; both are recognized here with std/parsec combinators, on the hot path (every annotated query). This makes sqlc an independent consumer of std/parsec alongside the other combinator users, exercising the same laws.
Index ¶
Constants ¶
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 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 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
}