core

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package core Auto-generated using python; DO NOT EDIT py 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 19:06:28) [MSC v.1942 64 bit (AMD64)]

Index

Constants

View Source
const (
	ModelTypeDataclass = "dataclass"
	ModelTypeAttrs     = "attrs"
	ModelTypeMsgspec   = "msgspec"
)
View Source
const (
	DocstringConventionNone   = "none"
	DocstringConventionGoogle = "google"
	DocstringConventionNumpy  = "numpy"
	DocstringConventionPEP257 = "pep257"
)
View Source
const PluginVersion = "v0.4.1"

Variables

This section is empty.

Functions

func ColumnName

func ColumnName(c *plugin.Column, pos int) string

func EnumReplace

func EnumReplace(value string) string

EnumReplace removes all non ident symbols (all but letters, numbers and underscore) and returns valid ident name for provided name.

func Escape

func Escape(s string) string

func IsAnyQueryMany added in v0.4.0

func IsAnyQueryMany(queries []Query) bool

func IsInMultipleMaps added in v0.4.0

func IsInMultipleMaps[K comparable, V any](search K, maps ...map[K]V) bool

func IsReserved

func IsReserved(s string) bool

func ModelName

func ModelName(enumName string, schemaName string, conf *Config) string

func ParamName

func ParamName(p *plugin.Parameter) string

func SQLToPyFileName

func SQLToPyFileName(s string) string

func SnakeToCamel

func SnakeToCamel(s string, conf *Config) string

func SplitLines added in v0.4.0

func SplitLines(s string) []string

func TableUses added in v0.4.0

func TableUses(name string, s Table) (bool, string)

func UpperSnakeCase

func UpperSnakeCase(s string) string

func ValidateConf

func ValidateConf(conf *Config, engine string) error

Types

type Column

type Column struct {
	Name    string // CamelCased name for Go
	DBName  string // Name as used in the DB
	Type    PyType
	Comment string
	Column  *plugin.Column
	// EmbedFields contains the embedded fields that require scanning.
	EmbedFields []Column
}

type Config

type Config struct {
	Package                     string        `json:"package" yaml:"package"`
	SqlDriver                   SQLDriverType `json:"sql_driver" yaml:"sql_driver"`
	ModelType                   string        `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"`
	QueryParameterLimit         *int32        `json:"query_parameter_limit,omitempty" yaml:"query_parameter_limit"`
	EmitInitFile                *bool         `json:"emit_init_file" yaml:"emit_init_file"`
	EmitDocstrings              *string       `json:"docstrings" yaml:"docstrings"`
	EmitDocstringsSQL           *bool         `json:"docstrings_emit_sql" yaml:"docstrings_emit_sql"`
	Speedups                    bool          `json:"speedups" yaml:"speedups"`
	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:"-"`
	Async          bool
}

func ParseConfig

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

type Constant

type Constant struct {
	Name  string
	Type  string
	Value string
}

type Enum

type Enum struct {
	Name      string
	Comment   string
	Constants []Constant
}

type FunctionArg added in v0.4.0

type FunctionArg struct {
	Name           string
	Type           string
	FunctionFormat string
}

type Importer

type Importer struct {
	Tables  []Table
	Queries []Query
	Enums   []Enum
	C       *Config
}

func (*Importer) Imports

func (i *Importer) Imports(fileName string) ([]string, []string, []string)

type PyType

type PyType struct {
	SqlType    string
	Type       string
	IsList     bool
	IsNullable bool
	IsEnum     bool
}

type Query

type Query struct {
	Cmd          string
	Comments     []string
	MethodName   string
	FuncName     string
	FieldName    string
	ConstantName string
	SQL          string
	SourceName   string
	Ret          QueryValue
	Args         []QueryValue

	// Used for :copyfrom
	Table *plugin.Identifier
}

func (Query) HasRetType

func (q Query) HasRetType() bool

type QueryValue

type QueryValue struct {
	Emit   bool
	Name   string
	DBName string // The name of the field in the database. Only set if Struct==nil.
	Table  *Table
	Typ    PyType

	// Column is kept so late in the generation process around to differentiate
	// between mysql slices and pg arrays
	Column *plugin.Column
}

func (QueryValue) EmitStruct

func (v QueryValue) EmitStruct() bool

func (QueryValue) IsEmpty

func (v QueryValue) IsEmpty() bool

func (QueryValue) IsStruct

func (v QueryValue) IsStruct() bool

func (QueryValue) Type

func (v QueryValue) Type() string

type SQLDriverType

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

func (*SQLDriverType) String

func (dr *SQLDriverType) String() string

type Table

type Table struct {
	Table   *plugin.Identifier
	Name    string
	Columns []Column
	Comment string
}

Jump to

Keyboard shortcuts

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