schema

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllDialects = []Dialect{Sqlite, Postgres, Mysql}
View Source
var Dialects []string

Functions

This section is empty.

Types

type Dialect

type Dialect interface {
	TableDDL(*TableDescription) string
	InsertDML(*TableDescription) string
	UpdateDML(*TableDescription) string
	DeleteDML(*TableDescription, FieldList) string
	TruncateDDL(tableName string, force bool) []string
	//Param(int) string
	CreateTableSettings() string
	FieldAsColumn(*Field) string

	ReplacePlaceholders(sql string) string
	Placeholders(n int) string
	String() string
}
var Mysql Dialect = mysql{}
var Postgres Dialect = postgres{}
var Sqlite Dialect = sqlite{}

type Field

type Field struct {
	Node
	SqlName string
	Encode  SqlEncode
	Tags    parse.Tag
}

func (*Field) IsExported

func (f *Field) IsExported() bool

type FieldList

type FieldList []*Field

func (FieldList) DistinctTypes

func (list FieldList) DistinctTypes() []Type

type Index

type Index struct {
	Name   string
	Unique bool

	Fields FieldList
}

func (*Index) Columns

func (i *Index) Columns() string

func (*Index) UniqueStr

func (i *Index) UniqueStr() string

type Node

type Node struct {
	Name   string
	Type   Type
	Parent *Node
}

func (*Node) JoinParts

func (node *Node) JoinParts(delta int, sep string) string

func (*Node) Parts

func (node *Node) Parts() []string

Parts gets the node containment chain as a sequence of names of parts.

type SqlEncode

type SqlEncode int
const (
	ENCNONE SqlEncode = iota
	ENCJSON
	ENCTEXT
	ENCDRIVER // SQL driver uses Scan() & Value() to encode & decode
)

List of vendor-specific keywords

type SqlToken

type SqlToken int
const (
	AUTO_INCREMENT SqlToken = iota
	PRIMARY_KEY
)

List of vendor-specific keywords

type TableDescription

type TableDescription struct {
	Type string
	Name string

	Fields  FieldList
	Index   []*Index
	Primary *Field // compound primaries are not supported
}

func (*TableDescription) ColumnNames

func (t *TableDescription) ColumnNames(withAuto bool) []string

func (*TableDescription) HasLastInsertId

func (t *TableDescription) HasLastInsertId() bool

func (*TableDescription) HasPrimaryKey

func (t *TableDescription) HasPrimaryKey() bool

func (*TableDescription) NumColumnNames

func (t *TableDescription) NumColumnNames(withAuto bool) int

func (*TableDescription) SimpleFields

func (t *TableDescription) SimpleFields() FieldList

type Type

type Type struct {
	PkgPath   string // package name (full path)
	PkgName   string // package name (short name)
	Name      string // name of source code type.
	IsPtr     bool
	IsScanner bool
	IsValuer  bool
	Base      Kind // underlying source code kind.
}

func (Type) NullableValue

func (t Type) NullableValue() string

func (Type) Star added in v0.8.0

func (t Type) Star() string

func (Type) String

func (t Type) String() string

func (Type) Tag

func (t Type) Tag() string

func (Type) Type

func (t Type) Type() string

type TypeSet

type TypeSet map[Type]struct{}

TypeSet is the primary type that represents a set

func BuildTypeSetFromChan

func BuildTypeSetFromChan(source <-chan Type) TypeSet

BuildTypeSetFromChan constructs a new TypeSet from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertTypeSet

func ConvertTypeSet(values ...interface{}) (TypeSet, bool)

ConvertTypeSet constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly.

func NewTypeSet

func NewTypeSet(values ...Type) TypeSet

NewTypeSet creates and returns a reference to an empty set.

func (TypeSet) Add

func (set TypeSet) Add(i ...Type) TypeSet

Add adds items to the current set, returning the modified set.

func (TypeSet) Append

func (set TypeSet) Append(more ...Type) TypeSet

Union returns a new set with all items in both sets.

func (TypeSet) Cardinality

func (set TypeSet) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*TypeSet) Clear

func (set *TypeSet) Clear()

Clear clears the entire set to be the empty set.

func (TypeSet) Clone

func (set TypeSet) Clone() TypeSet

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (TypeSet) Contains

func (set TypeSet) Contains(i Type) bool

Contains determines if a given item is already in the set.

func (TypeSet) ContainsAll

func (set TypeSet) ContainsAll(i ...Type) bool

ContainsAll determines if the given items are all in the set

func (TypeSet) CountBy

func (set TypeSet) CountBy(predicate func(Type) bool) (result int)

CountBy gives the number elements of TypeSet that return true for the passed predicate.

func (TypeSet) Difference

func (set TypeSet) Difference(other TypeSet) TypeSet

Difference returns a new set with items in the current set but not in the other set

func (TypeSet) Equals

func (set TypeSet) Equals(other TypeSet) bool

Equals determines if two sets are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (TypeSet) Exists

func (set TypeSet) Exists(fn func(Type) bool) bool

Exists applies a predicate function to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (TypeSet) Filter

func (set TypeSet) Filter(fn func(Type) bool) TypeSet

Filter returns a new TypeSet whose elements return true for func.

func (TypeSet) Forall

func (set TypeSet) Forall(fn func(Type) bool) bool

Forall applies a predicate function to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (TypeSet) Foreach

func (set TypeSet) Foreach(fn func(Type))

Foreach iterates over TypeSet and executes the passed func against each element.

func (TypeSet) Intersect

func (set TypeSet) Intersect(other TypeSet) TypeSet

Intersect returns a new set with items that exist only in both sets.

func (TypeSet) IsEmpty

func (set TypeSet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (TypeSet) IsSequence

func (set TypeSet) IsSequence() bool

IsSequence returns true for lists.

func (TypeSet) IsSet

func (set TypeSet) IsSet() bool

IsSet returns false for lists.

func (TypeSet) IsSubset

func (set TypeSet) IsSubset(other TypeSet) bool

IsSubset determines if every item in the other set is in this set.

func (TypeSet) IsSuperset

func (set TypeSet) IsSuperset(other TypeSet) bool

IsSuperset determines if every item of this set is in the other set.

func (TypeSet) MaxBy

func (set TypeSet) MaxBy(less func(Type, Type) bool) Type

MaxBy returns an element of TypeSet containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (TypeSet) MinBy

func (set TypeSet) MinBy(less func(Type, Type) bool) Type

MinBy returns an element of TypeSet containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (TypeSet) NonEmpty

func (set TypeSet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (TypeSet) Partition

func (set TypeSet) Partition(p func(Type) bool) (TypeSet, TypeSet)

Partition returns two new TypeLists whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list.

func (TypeSet) Remove

func (set TypeSet) Remove(i Type)

Remove allows the removal of a single item from the set.

func (TypeSet) Send

func (set TypeSet) Send() <-chan Type

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (TypeSet) Size

func (set TypeSet) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (TypeSet) SymmetricDifference

func (set TypeSet) SymmetricDifference(other TypeSet) TypeSet

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (TypeSet) ToInterfaceSlice

func (set TypeSet) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (TypeSet) ToSlice

func (set TypeSet) ToSlice() []Type

ToSlice returns the elements of the current set as a slice.

func (TypeSet) Union

func (set TypeSet) Union(other TypeSet) TypeSet

Union returns a new set with all items in both sets.

Jump to

Keyboard shortcuts

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