Documentation
¶
Overview ¶
Command pgc compiles annotated SQL queries into a type-safe Go package for PostgreSQL, using a live development database as its type oracle: every statement is prepared and described over the wire protocol - never executed and never parsed by pgc itself - so parameter and column types come from the server that will run them.
The generate command writes the package described by pgc.json; check runs the same compilation without writing, for CI; describe prints what the server reports about a single statement. The connection URL comes from PGC_DATABASE_URL, DATABASE_URL or the -d flag.
What the server said is recorded in pgc.lock.json, and generation falls back to that record when no URL is configured - so a fresh clone, a CI job and a container build produce the same package without a PostgreSQL to talk to. The verify command reports when the record and the database disagree.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
catalog
Package catalog resolves what Describe reports - bare OIDs - into names and nullability, by reading pg_type, pg_class and pg_attribute over the same connection.
|
Package catalog resolves what Describe reports - bare OIDs - into names and nullability, by reading pg_type, pg_class and pg_attribute over the same connection. |
|
compile
Package compile orchestrates one pgc run: parse the query files, ask the live database to describe every statement, resolve OIDs through the catalog, decide names and Go types, and hand a fully resolved model to gen.
|
Package compile orchestrates one pgc run: parse the query files, ask the live database to describe every statement, resolve OIDs through the catalog, decide names and Go types, and hand a fully resolved model to gen. |
|
config
Package config loads pgc.json.
|
Package config loads pgc.json. |
|
gen
Package gen renders the generated Go source.
|
Package gen renders the generated Go source. |
|
migrate
Package migrate applies plain-SQL migration files exactly once, in name order, recording what ran in a pgc_migrations table.
|
Package migrate applies plain-SQL migration files exactly once, in name order, recording what ran in a pgc_migrations table. |
|
pgwire
Package pgwire is a minimal PostgreSQL frontend: enough of the version 3 wire protocol to connect, authenticate and ask the server to describe a query.
|
Package pgwire is a minimal PostgreSQL frontend: enough of the version 3 wire protocol to connect, authenticate and ask the server to describe a query. |
|
queryfile
Package queryfile reads the annotated .sql files that feed pgc: it splits them into named queries, collects their documentation comments and decodes the per-query annotations (overrides and parameter names).
|
Package queryfile reads the annotated .sql files that feed pgc: it splits them into named queries, collects their documentation comments and decodes the per-query annotations (overrides and parameter names). |
|
snapshot
Package snapshot records what the database said about a set of queries, so a later run can generate the same code without one.
|
Package snapshot records what the database said about a set of queries, so a later run can generate the same code without one. |