Documentation
¶
Overview ¶
Package types contains xo internal types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey is a context key.
const ( DriverKey ContextKey = "driver" DbKey ContextKey = "db" SchemaKey ContextKey = "schema" )
Context key values.
type Field ¶
type Field struct {
Name string `json:"name,omitempty"`
Type Type `json:"datatype,omitempty"`
Default string `json:"default,omitempty"`
IsPrimary bool `json:"is_primary,omitempty"`
IsSequence bool `json:"is_sequence,omitempty"`
ConstValue *int `json:"const_value,omitempty"`
Interpolate bool `json:"interpolate,omitempty"`
Join bool `json:"join,omitempty"`
}
Field is a column, index, enum value, or stored procedure parameter.
type Flag ¶
type Flag struct {
ContextKey ContextKey
Type string
Desc string
PlaceHolder string
Default string
Short rune
Enums []string
}
Flag is a option flag.
type ForeignKey ¶
type ForeignKey struct {
Name string `json:"name,omitempty"` // constraint name
Fields []Field `json:"column,omitempty"` // column that has the key on it
RefTable string `json:"ref_table,omitempty"` // table the foreign key refers to
RefFields []Field `json:"ref_column,omitempty"` // column in ref table the index refers to
Func string `json:"-"` // foreign key func name (based on fkey mode)
RefFunc string `json:"-"` // func name from ref index
}
ForeignKey is a foreign key.
type Index ¶
type Index struct {
Name string `json:"name,omitempty"`
Fields []Field `json:"fields,omitempty"`
IsUnique bool `json:"is_unique,omitempty"`
IsPrimary bool `json:"is_primary,omitempty"`
Func string `json:"-"`
}
Index is a index.
type Proc ¶
type Proc struct {
ID string `json:"-"`
Type string `json:"type,omitempty"` // 'procedure' or 'function'
Name string `json:"name,omitempty"`
Params []Field `json:"params,omitempty"`
Returns []Field `json:"return,omitempty"`
Void bool `json:"void,omitempty"`
Definition string `json:"definition,omitempty"`
}
Proc is a stored procedure.
func (Proc) MarshalYAML ¶
MarshalYAML satisfies the yaml.Marshaler interface.
type Query ¶
type Query struct {
Driver string `json:"driver,omitempty"`
Name string `json:"name,omitempty"`
Comment string `json:"comment,omitempty"`
Exec bool `json:"exec,omitempty"`
Flat bool `json:"flat,omitempty"`
One bool `json:"one,omitempty"`
Interpolate bool `json:"interpolate,omitempty"`
Type string `json:"type,omitempty"`
TypeComment string `json:"type_comment,omitempty"`
Fields []Field `json:"fields,omitempty"`
ManualFields bool `json:"manual_fields,omitempty"` // fields generated or provided by user
Params []Field `json:"params,omitempty"`
Query []string `json:"query,omitempty"`
Comments []string `json:"comments,omitempty"`
}
Query is a query.
func (Query) MarshalYAML ¶
MarshalYAML satisfies the yaml.Marshaler interface.
type Schema ¶
type Schema struct {
Driver string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Enums []Enum `json:"enums,omitempty"`
Procs []Proc `json:"procs,omitempty"`
Tables []Table `json:"tables,omitempty"`
Views []Table `json:"views,omitempty"`
}
Schema is a SQL schema.
func (Schema) EnumByName ¶
EnumByName returns a enum by its name.
type Table ¶
type Table struct {
Type string `json:"type,omitempty"` // 'table' or 'view'
Name string `json:"name,omitempty"`
Columns []Field `json:"columns,omitempty"`
PrimaryKeys []Field `json:"primary_keys,omitempty"`
Indexes []Index `json:"indexes,omitempty"`
ForeignKeys []ForeignKey `json:"foreign_keys,omitempty"`
Manual bool `json:"manual,omitempty"`
Definition string `json:"definition,omitempty"` // empty for tables
}
Table is a table or view.
func (Table) MarshalYAML ¶
MarshalYAML satisfies the yaml.Marshaler interface.
type Type ¶
type Type struct {
Type string `json:"type,omitempty"`
Prec int `json:"prec,omitempty"`
Scale int `json:"scale,omitempty"`
Nullable bool `json:"nullable,omitempty"`
IsArray bool `json:"array,omitempty"`
Unsigned bool `json:"unsigned,omitempty"`
Enum *Enum `json:"-"`
}
Type holds information for a database type.
func ParseType ¶
ParseType parses "type[ (precision[,scale])][\[\]]" strings returning the parsed precision, scale, and if the type is an array or not.
Expected formats:
type type(precision) type(precision, scale) type(precision, scale) unsigned timestamp(n) with [local] time zone (oracle only)
The returned type is stripped of precision and scale.