core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: MIT Imports: 10 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"
)
View Source
const PluginVersion = "v0.1.0"

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 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 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"`
	EmitExactTableNames         bool          `json:"emit_exact_table_names,omitempty" 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"`
	OmitUnusedStructs           bool          `json:"omit_unused_structs,omitempty" yaml:"omit_unused_structs"`
	QueryParameterLimit         *int32        `json:"query_parameter_limit,omitempty" yaml:"query_parameter_limit"`

	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 Importer

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

func (*Importer) Imports

func (i *Importer) Imports(fileName 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"
)

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