config

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const PluginVersion = "v0.5.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Package                     string              `json:"package"                                  yaml:"package"`
	SqlDriver                   SQLDriver           `json:"sql_driver"                               yaml:"sql_driver"`
	ModelType                   ModelType           `json:"model_type"                               yaml:"model_type"`
	Initialisms                 *[]string           `json:"initialisms,omitempty"                    yaml:"initialisms,omitempty"`
	EmitExactTableNames         bool                `json:"emit_exact_table_names"                   yaml:"emit_exact_table_names"`
	EmitClasses                 bool                `json:"emit_classes"                             yaml:"emit_classes"`
	InflectionExcludeTableNames []string            `json:"inflection_exclude_table_names,omitempty" yaml:"inflection_exclude_table_names,omitempty"`
	OmitUnusedModels            bool                `json:"omit_unused_models"                       yaml:"omit_unused_models"`
	OmitTypecheckingBlock       bool                `json:"omit_typechecking_block"                  yaml:"omit_typechecking_block"`
	QueryParameterLimit         *int                `json:"query_parameter_limit,omitempty"          yaml:"query_parameter_limit"`
	OmitKwargsLimit             int                 `json:"omit_kwargs_limit,omitempty"              yaml:"omit_kwargs_limit"`
	EmitInitFile                *bool               `json:"emit_init_file"                           yaml:"emit_init_file"`
	EmitDocstrings              DocstringConvention `json:"docstrings"                               yaml:"docstrings"`
	EmitDocstringsSQL           *bool               `json:"docstrings_emit_sql"                      yaml:"docstrings_emit_sql"`
	Speedups                    bool                `json:"speedups"                                 yaml:"speedups"`
	Overrides                   []Override          `json:"overrides,omitempty"                      yaml:"overrides,omitempty"`

	Debug bool `json:"debug" yaml:"debug"`

	IndentChar          string `json:"indent_char"            yaml:"indent_char"`
	CharsPerIndentLevel int    `json:"chars_per_indent_level" yaml:"chars_per_indent_level"`

	InitialismsMap map[string]struct{} `json:"-" yaml:"-"`
}

func NewConfig

func NewConfig(req *plugin.GenerateRequest) (*Config, error)

func (*Config) IsOverQueryParameterLimit

func (config *Config) IsOverQueryParameterLimit(num int) bool

IsOverQueryParameterLimit reports whether a query's parameters should be bundled into a Params class. This is opt-in: it only applies when query_parameter_limit is explicitly set to a non-negative value and the query has more parameters than the limit.

type DocstringConvention

type DocstringConvention string
const (
	DocstringConventionNone   DocstringConvention = "none"
	DocstringConventionGoogle DocstringConvention = "google"
	DocstringConventionNumpy  DocstringConvention = "numpy"
	DocstringConventionPEP257 DocstringConvention = "pep257"
)

func (DocstringConvention) Valid

func (ds DocstringConvention) Valid() bool

type ModelType

type ModelType string
const (
	ModelTypeDataclass ModelType = "dataclass"
	ModelTypeAttrs     ModelType = "attrs"
	ModelTypeMsgspec   ModelType = "msgspec"
	ModelTypePydantic  ModelType = "pydantic"
)

func (ModelType) Valid

func (modelType ModelType) Valid() bool

type Override

type Override struct {
	PyType OverridePyType `json:"py_type" yaml:"py_type"`

	// DBType matches the SQL data type exactly, e.g. "text" or "pg_catalog.int4".
	DBType string `json:"db_type" yaml:"db_type"`

	// Column matches a fully qualified column name, e.g. "authors.name".
	Column string `json:"column" yaml:"column"`

	ColumnName   *pattern.Match `json:"-" yaml:"-"`
	TableCatalog *pattern.Match `json:"-" yaml:"-"`
	TableSchema  *pattern.Match `json:"-" yaml:"-"`
	TableRel     *pattern.Match `json:"-" yaml:"-"`
}

Override replaces the default Python type of columns matched either by SQL type (DBType) or by a column pattern ("[catalog.][schema.]table.column", wildcards supported).

func (*Override) Matches

func (o *Override) Matches(n *plugin.Identifier, defaultSchema string) bool

Matches reports whether the override's table pattern matches the identifier.

type OverridePyType

type OverridePyType struct {
	Import  string `json:"import"  yaml:"import"`
	Type    string `json:"type"    yaml:"type"`
	Package string `json:"package" yaml:"package"`
}

OverridePyType describes the Python type that replaces the default mapping. Import is the module to import (e.g. "collections"); Type is the type expression used in annotations (e.g. "UserString" or "collections.UserString"); Package is the name imported from Import ("from <import> import <package>") - if empty, Import is imported as a plain module ("import <import>").

type SQLDriver

type SQLDriver string
const (
	SQLDriverSQLite    SQLDriver = "sqlite3"
	SQLDriverAioSQLite SQLDriver = "aiosqlite"
	SQLDriverAsyncpg   SQLDriver = "asyncpg"
)

func (SQLDriver) String

func (dr SQLDriver) String() string

func (SQLDriver) Validate

func (dr SQLDriver) Validate(engine string) error

Jump to

Keyboard shortcuts

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