query

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package query parses named DML query files (sqlc-style annotations) and maps each query to a pluginv1.Query IR node.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Infer

func Infer(q *pluginv1.Query, cat *irv1.Catalog, d *catalog.Diagnostics)

Infer mutates q by:

  1. Walking the AST to collect parameters and their explicit cast types.
  2. Attempting shallow type inference for parameters by examining operator operands — if a param appears beside a resolved ColumnRef, the param inherits the column's type.
  3. For SELECT queries, resolving SelectTarget nodes to QueryColumn entries.

Unresolvable items produce a diagnostic but never a panic.

func ParseQueries

func ParseQueries(sql, sourceFile string) ([]*pluginv1.Query, error)

ParseQueries scans sql for named query blocks, parses each, and returns the resulting []*pluginv1.Query.

A query block begins with a header comment:

-- name: QueryName :command

and extends until the next header (or EOF). Invalid SQL or parameter macros return an error identifying the source file and query.

Types

This section is empty.

Jump to

Keyboard shortcuts

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