config

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingEngine = errors.New("unknown engine")
View Source
var ErrMissingVersion = errors.New("no version number")
View Source
var ErrNoOutPath = errors.New("no output path")
View Source
var ErrNoPackageName = errors.New("missing package name")
View Source
var ErrNoPackagePath = errors.New("missing package path")
View Source
var ErrNoPackages = errors.New("no packages")
View Source
var ErrNoQuerierType = errors.New("no querier emit type enabled")
View Source
var ErrUnknownEngine = errors.New("invalid engine")
View Source
var ErrUnknownVersion = errors.New("invalid version number")

Functions

This section is empty.

Types

type CombinedSettings

type CombinedSettings struct {
	Global    Config
	Package   SQL
	Go        SQLGo
	Kotlin    SQLKotlin
	Python    SQLPython
	Rename    map[string]string
	Overrides []Override
}

func Combine

func Combine(conf Config, pkg SQL) CombinedSettings

type Config

type Config struct {
	Version string `json:"version" yaml:"version"`
	SQL     []SQL  `json:"sql" yaml:"sql"`
	Gen     Gen    `json:"overrides,omitempty" yaml:"overrides"`
}

func ParseConfig

func ParseConfig(rd io.Reader) (Config, error)

type Engine

type Engine string
const (
	EngineMySQL      Engine = "mysql"
	EnginePostgreSQL Engine = "postgresql"

	// Experimental engines
	EngineXLemon Engine = "_lemon"
)

type Gen

type Gen struct {
	Go     *GenGo     `json:"go,omitempty" yaml:"go"`
	Kotlin *GenKotlin `json:"kotlin,omitempty" yaml:"kotlin"`
}

type GenGo

type GenGo struct {
	Overrides []Override        `json:"overrides,omitempty" yaml:"overrides"`
	Rename    map[string]string `json:"rename,omitempty" yaml:"rename"`
}

type GenKotlin

type GenKotlin struct {
	Rename map[string]string `json:"rename,omitempty" yaml:"rename"`
}

type GoType added in v1.6.0

type GoType struct {
	Path    string `json:"import" yaml:"import"`
	Package string `json:"package" yaml:"package"`
	Name    string `json:"type" yaml:"type"`
	Pointer bool   `json:"pointer" yaml:"pointer"`
	Spec    string
	BuiltIn bool
}

func (GoType) Parse added in v1.6.0

func (gt GoType) Parse() (*ParsedGoType, error)

validate GoType

func (*GoType) UnmarshalJSON added in v1.6.0

func (o *GoType) UnmarshalJSON(data []byte) error

func (*GoType) UnmarshalYAML added in v1.6.0

func (o *GoType) UnmarshalYAML(unmarshal func(interface{}) error) error

type Override

type Override struct {
	// name of the golang type to use, e.g. `github.com/segmentio/ksuid.KSUID`
	GoType GoType `json:"go_type" yaml:"go_type"`

	// name of the python type to use, e.g. `mymodule.TypeName`
	PythonType PythonType `json:"python_type" yaml:"python_type"`

	// fully qualified name of the Go type, e.g. `github.com/segmentio/ksuid.KSUID`
	DBType                  string `json:"db_type" yaml:"db_type"`
	Deprecated_PostgresType string `json:"postgres_type" yaml:"postgres_type"`

	// for global overrides only when two different engines are in use
	Engine Engine `json:"engine,omitempty" yaml:"engine"`

	// True if the GoType should override if the maching postgres type is nullable
	Nullable bool `json:"nullable" yaml:"nullable"`
	// Deprecated. Use the `nullable` property instead
	Deprecated_Null bool `json:"null" yaml:"null"`

	// fully qualified name of the column, e.g. `accounts.id`
	Column string `json:"column" yaml:"column"`

	ColumnName   string
	Table        core.FQN
	GoImportPath string
	GoPackage    string
	GoTypeName   string
	GoBasicType  bool
}

func (*Override) Parse

func (o *Override) Parse() error

type ParsedGoType added in v1.6.0

type ParsedGoType struct {
	ImportPath string
	Package    string
	TypeName   string
	BasicType  bool
}

type Paths added in v1.2.0

type Paths []string

func (*Paths) UnmarshalJSON added in v1.2.0

func (p *Paths) UnmarshalJSON(data []byte) error

func (*Paths) UnmarshalYAML added in v1.2.0

func (p *Paths) UnmarshalYAML(unmarshal func(interface{}) error) error

type PythonType added in v1.8.0

type PythonType struct {
	Module string `json:"module" yaml:"module"`
	Name   string `json:"name" yaml:"name"`
}

func (PythonType) IsSet added in v1.8.0

func (t PythonType) IsSet() bool

func (PythonType) TypeString added in v1.8.0

func (t PythonType) TypeString() string

type SQL

type SQL struct {
	Engine  Engine `json:"engine,omitempty" yaml:"engine"`
	Schema  Paths  `json:"schema" yaml:"schema"`
	Queries Paths  `json:"queries" yaml:"queries"`
	Gen     SQLGen `json:"gen" yaml:"gen"`
}

type SQLGen

type SQLGen struct {
	Go     *SQLGo     `json:"go,omitempty" yaml:"go"`
	Kotlin *SQLKotlin `json:"kotlin,omitempty" yaml:"kotlin"`
	Python *SQLPython `json:"python,omitempty" yaml:"python"`
}

type SQLGo

type SQLGo struct {
	EmitInterface       bool              `json:"emit_interface" yaml:"emit_interface"`
	EmitJSONTags        bool              `json:"emit_json_tags" yaml:"emit_json_tags"`
	EmitDBTags          bool              `json:"emit_db_tags" yaml:"emit_db_tags"`
	EmitPreparedQueries bool              `json:"emit_prepared_queries" yaml:"emit_prepared_queries"`
	EmitExactTableNames bool              `json:"emit_exact_table_names,omitempty" yaml:"emit_exact_table_names"`
	EmitEmptySlices     bool              `json:"emit_empty_slices,omitempty" yaml:"emit_empty_slices"`
	JSONTagsCaseStyle   string            `json:"json_tags_case_style,omitempty" yaml:"json_tags_case_style"`
	Package             string            `json:"package" yaml:"package"`
	Out                 string            `json:"out" yaml:"out"`
	Overrides           []Override        `json:"overrides,omitempty" yaml:"overrides"`
	Rename              map[string]string `json:"rename,omitempty" yaml:"rename"`
}

type SQLKotlin

type SQLKotlin struct {
	EmitExactTableNames bool   `json:"emit_exact_table_names,omitempty" yaml:"emit_exact_table_names"`
	Package             string `json:"package" yaml:"package"`
	Out                 string `json:"out" yaml:"out"`
}

type SQLPython added in v1.8.0

type SQLPython struct {
	EmitExactTableNames bool       `json:"emit_exact_table_names" yaml:"emit_exact_table_names"`
	EmitSyncQuerier     bool       `json:"emit_sync_querier" yaml:"emit_sync_querier"`
	EmitAsyncQuerier    bool       `json:"emit_async_querier" yaml:"emit_async_querier"`
	Package             string     `json:"package" yaml:"package"`
	Out                 string     `json:"out" yaml:"out"`
	Overrides           []Override `json:"overrides,omitempty" yaml:"overrides"`
}

type V1GenerateSettings

type V1GenerateSettings struct {
	Version   string              `json:"version" yaml:"version"`
	Packages  []v1PackageSettings `json:"packages" yaml:"packages"`
	Overrides []Override          `json:"overrides,omitempty" yaml:"overrides,omitempty"`
	Rename    map[string]string   `json:"rename,omitempty" yaml:"rename,omitempty"`
}

func (*V1GenerateSettings) Translate

func (c *V1GenerateSettings) Translate() Config

func (*V1GenerateSettings) ValidateGlobalOverrides

func (c *V1GenerateSettings) ValidateGlobalOverrides() error

Jump to

Keyboard shortcuts

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