Documentation
¶
Overview ¶
Package codegen orchestrates the generation of Go code from SQL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportedIdentifier ¶
ExportedIdentifier converts raw input into a public Go identifier.
func UnexportedIdentifier ¶
UnexportedIdentifier converts raw input into a private Go identifier.
Types ¶
type Generator ¶
type Generator interface {
Generate(ctx context.Context, catalog *model.Catalog, analyses []analyzer.Result) ([]File, error)
}
Generator produces Go code from parsed schemas and queries.
type GeneratorFactory ¶
type GeneratorFactory struct {
// contains filtered or unexported fields
}
GeneratorFactory creates language-specific generators.
func NewGeneratorFactory ¶
func NewGeneratorFactory(opts Options) *GeneratorFactory
NewGeneratorFactory creates a new generator factory.
type Options ¶
type Options struct {
Package string
Database config.Database
EmitJSONTags bool
EmitEmptySlices bool
EmitPointersForNull bool
// G7 emit_* options. Each defaults to the pre-G7 behavior (see ast.Options).
EmitDBTags bool
JSONTagsCaseStyle string
EmitResultStructPointers bool
EmitParamsStructPointers bool
// SuppressInterface skips the Querier interface (querier.gen.go). The zero
// value (false) emits it, matching db-catalyst's always-emit default, so a
// bare codegen.Options{} reproduces the pre-G7 output. emit_interface = false
// sets this to true via the pipeline.
SuppressInterface bool
// Initialisms renders SQL-derived Go identifiers with the golint/sqlc
// initialism table (user_id → UserID). Default false keeps legacy casing.
Initialisms bool
// Rename maps exact SQL names to exported Go identifiers, winning over
// Initialisms and applying regardless of that flag.
Rename map[string]string
Prepared PreparedOptions
CustomTypes []config.CustomTypeMapping
ColumnOverrides []config.ColumnOverride
SQL SQLOptions
// ModelsPackage, when non-empty, emits the table-model structs into a
// separate sub-package of this name (and sub-directory under Out).
ModelsPackage string
// ModelsImport is the full import path of the models sub-package, used by
// the main package files to reference the split model types.
ModelsImport string
}
Options configures the Generator.
type PreparedOptions ¶
PreparedOptions configures prepared statement generation.
type SQLOptions ¶
SQLOptions configures SQL schema output.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ast provides types and logic for building Go ASTs.
|
Package ast provides types and logic for building Go ASTs. |
|
Package render formats and writes generated Go code.
|
Package render formats and writes generated Go code. |
|
Package rust generates Rust code using text templates.
|
Package rust generates Rust code using text templates. |
|
Package sql generates SQL schema definitions from a database catalog.
|
Package sql generates SQL schema definitions from a database catalog. |
|
Package typescript generates TypeScript code using text templates.
|
Package typescript generates TypeScript code using text templates. |
Click to show internal directories.
Click to hide internal directories.