Documentation
¶
Index ¶
Constants ¶
const PluginVersion = "v0.6.0"
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"`
Converters []Converter `json:"converters,omitempty" yaml:"converters,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 (*Config) IsOverQueryParameterLimit ¶
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 Converter ¶ added in v0.6.0
type Converter struct {
Name string `json:"name" yaml:"name"`
PyType OverridePyType `json:"py_type" yaml:"py_type"`
ToDB string `json:"to_db" yaml:"to_db"`
FromDB string `json:"from_db" yaml:"from_db"`
}
Converter names a pair of user functions that translate a column value between its Python type and the type the driver expects. Both are dotted paths; the module is imported and the function called fully qualified.
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 Override ¶
type Override struct {
PyType OverridePyType `json:"py_type" yaml:"py_type"`
// Converter names an entry in the top-level converters list, supplying
// both the Python type and the functions converting to and from it.
Converter string `json:"converter" yaml:"converter"`
Resolved *Converter `json:"-" yaml:"-"`
// 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).
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>").