Documentation
¶
Overview ¶
Package block handles the parsing of SQL query blocks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
Path string
Name string
Command Command
SQL string
Doc string
Line int
Column int
StartOffset int
EndOffset int
Suffix string
ParamTypes []ParamTypeOverride // Explicit type overrides from @param comments
ReturnTypes []ReturnTypeOverride // Explicit type overrides from @returns comments
Cache *cache.Annotation // Cache annotation if present
// OrderBy holds the allow-list of column names from an `-- @orderby col, col2`
// annotation, in source order. It is only set when the query uses the dynamic
// ORDER BY feature (a `@orderby` placeholder in the ORDER BY position). Nil for
// every query that does not use the annotation, keeping output unchanged.
OrderBy []string
// Optional holds the names of optional equality-filter params from an
// `-- @optional p1, p2` annotation, in source order. It is only set when the
// query uses the optional-filters feature (each param wrapped in a
// `(@p IS NULL OR <expr> <op> @p)` clause). Nil for every query that does not
// use the annotation, keeping output unchanged.
Optional []string
}
Block represents a parsed SQL query block.
type Command ¶
type Command int
Command represents the type of query (one, many, exec, etc.).
const ( // CommandUnknown indicates an unrecognized command. CommandUnknown Command = iota // CommandOne indicates a query returning a single row. CommandOne // CommandMany indicates a query returning multiple rows. CommandMany // CommandExec indicates a query that executes without returning rows. CommandExec // CommandExecResult indicates a query that returns execution result (rows affected, etc.). CommandExecResult // CommandExecRows indicates a query that returns the number of affected rows. CommandExecRows // CommandExecLastID indicates a query that returns the last insert ID. CommandExecLastID // CommandCopyFrom indicates a bulk insert that takes a slice of param structs and inserts all rows in one statement. CommandCopyFrom // CommandBatchExec indicates a batch that runs the statement once per param set, returning only error. CommandBatchExec // CommandBatchMany indicates a batch that runs a query once per param set, returning a slice of row slices ([][]Row). CommandBatchMany // CommandBatchOne indicates a batch that runs a query once per param set, returning one row per set ([]Row). CommandBatchOne )
func ParseCommand ¶
ParseCommand parses a command tag (e.g., ":one") into a Command.
type ParamTypeOverride ¶ added in v0.5.0
ParamTypeOverride represents an explicit type override for a parameter.
type ReturnTypeOverride ¶ added in v0.11.0
ReturnTypeOverride represents an explicit type override for a result column.
Click to show internal directories.
Click to hide internal directories.