internal

package
v0.0.0-...-cf8841b Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedType = errors.New("unsupported type")

Functions

func Render

func Render(pkgName, structName string, obj Struct, w io.Writer) error

Types

type Column

type Column struct {
	Name string
	Type string
}

func (Column) ToField

func (c Column) ToField() (f Field, err error)

type Field

type Field struct {
	Name    string
	Type    string
	Tag     string
	Imports []string
	Consts  map[string]string
	Column  Column
}

type RenderData

type RenderData struct {
	PackageName string
	Struct      Struct
	Imports     []string
}

type Struct

type Struct struct {
	Name   string
	Table  Table
	Fields []Field
}

type Table

type Table struct {
	Name    string
	Columns []Column
}

func Introspect

func Introspect(ctx context.Context, conn clickhouse.Conn, dbName, tableName string) (t Table, err error)

func (Table) ToStruct

func (t Table) ToStruct() (Struct, error)

type Type

type Type struct {
	Unary *TypeUnary `parser:"  @@"`
	Array *TypeArray `parser:"| @@"`
	Map   *TypeMap   `parser:"| @@"`
	Enum  *TypeEnum  `parser:"| @@"`
}

func ParseType

func ParseType(exp string) (*Type, error)

func (Type) Field

func (t Type) Field() (Field, error)

type TypeArray

type TypeArray struct {
	Type TypeUnary `parser:"  'Array' '(' @@ ')'"`
}

func (*TypeArray) Field

func (t *TypeArray) Field() (Field, error)

type TypeEnum

type TypeEnum struct {
	Elems []TypeEnumElem `parser:"('Enum8' | 'Enum16') '(' ( @@ ','? )+ ')'"`
}

func (TypeEnum) Field

func (t TypeEnum) Field() (Field, error)

type TypeEnumElem

type TypeEnumElem struct {
	Label string `parser:"     @(String|Char)"`
	Value int    `parser:" '=' @(Int)"`
}

type TypeFixedString

type TypeFixedString struct {
	Length int `parser:"'FixedString' '(' @Int ')'"`
}

func (TypeFixedString) Field

func (t TypeFixedString) Field() (Field, error)

type TypeLowCardinalityUnary

type TypeLowCardinalityUnary struct {
	Type TypeUnary `parser:"'LowCardinality' '(' @@ ')'"`
}

func (TypeLowCardinalityUnary) Field

func (t TypeLowCardinalityUnary) Field() (Field, error)

type TypeMap

type TypeMap struct {
	KeyType   TypeUnary `parser:"'Map' '(' @@"`
	ValueType TypeUnary `parser:"            ',' @@ ')'"`
}

func (TypeMap) Field

func (t TypeMap) Field() (f Field, err error)

type TypeNullableUnary

type TypeNullableUnary struct {
	Type TypeUnary `parser:"'Nullable' '(' @@ ')'"`
}

func (TypeNullableUnary) Field

func (t TypeNullableUnary) Field() (Field, error)

type TypeUnary

type TypeUnary struct {
	Unary          *TypeUnaryUnary          `parser:"  @@"`
	Nullable       *TypeNullableUnary       `parser:"| @@"`
	LowCardinality *TypeLowCardinalityUnary `parser:"| @@"`
	FixedString    *TypeFixedString         `parser:"| @@"` // it's not exactly unary at db side, but resulting Go type is merely a string
}

func (TypeUnary) Field

func (t TypeUnary) Field() (f Field, err error)

type TypeUnaryUnary

type TypeUnaryUnary struct {
	Type string `` /* 318-byte string literal not displayed */
}

func (TypeUnaryUnary) Field

func (t TypeUnaryUnary) Field() (Field, error)

Jump to

Keyboard shortcuts

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