Documentation
¶
Overview ¶
Package sqletch is the user-facing companion of sqletch-generated code: types application code writes at call sites. The composition machinery generated code runs on lives in the runtime subpackage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Omittable ¶
type Omittable[T any] struct { // contains filtered or unexported fields }
Omittable is the value of an @if-present (presence guard) parameter. The zero value is omitted: every fragment the parameter guards is left out of the composed SQL, so an INSERT column falls back to its DEFAULT and an UPDATE SET item leaves the column untouched. Present provides a value.
Omission is a query-shape concept, distinct from SQL NULL, which generated code spells optional.Option[T] (design 20). A guarded parameter that writes a nullable column is therefore Omittable[optional.Option[T]]: omitted, Present(None) for NULL, or Present(Some(v)).
func Present ¶
Present returns a provided Omittable holding v. Presence is never inferred from the value: Present of a zero value is still present.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
sqletch
command
Command sqletch is the statically verified, dynamically composed SQL compiler for Go.
|
Command sqletch is the statically verified, dynamically composed SQL compiler for Go. |
|
examples
|
|
|
mysql
command
A runnable sqletch MySQL showcase.
|
A runnable sqletch MySQL showcase. |
|
postgres
command
The examples app exercises the generated API end to end.
|
The examples app exercises the generated API end to end. |
|
sqlite
command
A zero-setup, runnable sqletch showcase: SQLite needs no server and no Docker — `go run .` seeds a throwaway database file and queries it through the generated, compile-time-verified API.
|
A zero-setup, runnable sqletch showcase: SQLite needs no server and no Docker — `go run .` seeds a throwaway database file and queries it through the generated, compile-time-verified API. |
|
internal
|
|
|
ast
Package ast implements phase P2: building verified renderings from a scanned template, with exact source maps back to the template file.
|
Package ast implements phase P2: building verified renderings from a scanned template, with exact source maps back to the template file. |
|
cache
Package cache holds the committed oracle cache and the catalog snapshot model.
|
Package cache holds the committed oracle cache and the catalog snapshot model. |
|
cli
Package cli implements the sqletch commands as testable functions; cmd/sqletch is thin cobra wiring over these.
|
Package cli implements the sqletch commands as testable functions; cmd/sqletch is thin cobra wiring over these. |
|
codegen
Package codegen emits the generated Go package: fragment tables, typed params/row structs, and one function per query.
|
Package codegen emits the generated Go package: fragment tables, typed params/row structs, and one function per query. |
|
config
Package config loads and validates sqletch.yaml.
|
Package config loads and validates sqletch.yaml. |
|
corpus
Package corpus is the oracle ground-truth corpus harness (design 15 §7.2).
|
Package corpus is the oracle ground-truth corpus harness (design 15 §7.2). |
|
devdb
Package devdb manages the development database the type oracle runs against: a user-supplied DSN, or an auto-managed disposable container.
|
Package devdb manages the development database the type oracle runs against: a user-supplied DSN, or an auto-managed disposable container. |
|
diagnostics
Package diagnostics defines the user-facing error model shared by every compiler phase.
|
Package diagnostics defines the user-facing error model shared by every compiler phase. |
|
dialect
Package dialect defines the driver interfaces separating the dialect-agnostic core from database specifics.
|
Package dialect defines the driver interfaces separating the dialect-agnostic core from database specifics. |
|
dialect/dialecttest
Package dialecttest holds cross-dialect conformance helpers shared by the dialect packages' tests.
|
Package dialecttest holds cross-dialect conformance helpers shared by the dialect packages' tests. |
|
dialect/mysql
Package mysql implements the MySQL dialect driver (Tier 2).
|
Package mysql implements the MySQL dialect driver (Tier 2). |
|
dialect/postgres
Package postgres implements the PostgreSQL dialect driver.
|
Package postgres implements the PostgreSQL dialect driver. |
|
dialect/sqlite
Package sqlite implements the SQLite dialect driver (Tier 2).
|
Package sqlite implements the SQLite dialect driver (Tier 2). |
|
gosrc
Package gosrc extracts template text from Go source files.
|
Package gosrc extracts template text from Go source files. |
|
lint
Package lint implements the opt-in performance lints SQLETCHL001–L006 (docs/design/24-performance-lints.md).
|
Package lint implements the opt-in performance lints SQLETCHL001–L006 (docs/design/24-performance-lints.md). |
|
lsp
Package lsp implements the sqletch language server (docs/design/10-lsp.md): JSON-RPC 2.0 over stdio, a subset of the Language Server Protocol (diagnostics + go-to-definition), backed by an injected Workspace checker so the protocol layer never touches dialect drivers or the pipeline directly.
|
Package lsp implements the sqletch language server (docs/design/10-lsp.md): JSON-RPC 2.0 over stdio, a subset of the Language Server Protocol (diagnostics + go-to-definition), backed by an injected Workspace checker so the protocol layer never touches dialect drivers or the pipeline directly. |
|
nullability
Package nullability decides, per result column, whether the generated Go field must be a pointer — under the spec's per-shape-sound discipline: narrowing uses only the skeleton; guarded fragments NEVER narrow.
|
Package nullability decides, per result column, whether the generated Go field must be a pointer — under the spec's per-shape-sound discipline: narrowing uses only the skeleton; guarded fragments NEVER narrow. |
|
pathpat
Package pathpat compiles and expands sqletch's query-file patterns: project-relative globs with recursive `**` segments and capture groups whose matched text is substituted into a target's output path (docs/design/19-multi-target-output.md §3).
|
Package pathpat compiles and expands sqletch's query-file patterns: project-relative globs with recursive `**` segments and capture groups whose matched text is substituted into a target's output path (docs/design/19-multi-target-output.md §3). |
|
policy
Package policy implements cross-query policy weaving (design 14, spec §"Cross-Query Policies"): a boolean predicate declared once in sqletch.yaml, woven after the P1 scan and before rendering into every query that touches a designated table.
|
Package policy implements cross-query policy weaving (design 14, spec §"Cross-Query Policies"): a boolean predicate declared once in sqletch.yaml, woven after the P1 scan and before rendering into every query that touches a designated table. |
|
rules
Package rules implements the structural rule checks R1–R9.
|
Package rules implements the structural rule checks R1–R9. |
|
shape
Package shape computes and enumerates the reachable query shapes of a template: guard bitmask × one ordinal per @choose block.
|
Package shape computes and enumerates the reachable query shapes of a template: guard bitmask × one ordinal per @choose block. |
|
template
Package template implements phase P1: scanning .sql template files into a structured model (constant skeleton + guarded fragments) with exact source spans.
|
Package template implements phase P1: scanning .sql template files into a structured model (constant skeleton + guarded fragments) with exact source spans. |
|
Package runtime is the small public package imported by sqletch-generated code.
|
Package runtime is the small public package imported by sqletch-generated code. |
|
spike
|
|
|
wasm-oracle
command
Command wasm-oracle is the v0.4 spike mandated by docs/design/08-later-phases.md: boot libpglite's WASI build of PostgreSQL 16 in-process under wazero, expose its file-transport wire pump as a net.Conn, and run sqletch's UNMODIFIED postgres oracle (pgx-based) against it — Describe, Plan (GENERIC_PLAN), PlanText, Snapshot, ServerVersion — measuring cold-start against the < 2s budget and probing error recovery.
|
Command wasm-oracle is the v0.4 spike mandated by docs/design/08-later-phases.md: boot libpglite's WASI build of PostgreSQL 16 in-process under wazero, expose its file-transport wire pump as a net.Conn, and run sqletch's UNMODIFIED postgres oracle (pgx-based) against it — Describe, Plan (GENERIC_PLAN), PlanText, Snapshot, ServerVersion — measuring cold-start against the < 2s budget and probing error recovery. |