Documentation ¶
Index ¶
- Variables
- func IsExpression(value interface{}) bool
- func Register(name string, grammar Grammar)
- type Aggregate
- type Column
- type Command
- type Config
- type Connection
- type Constraint
- type Expression
- type From
- type Grammar
- type Having
- type Index
- type Join
- type Name
- type Option
- type Order
- type Primary
- type Query
- func (query *Query) AddBinding(typ string, value interface{})
- func (query *Query) AddColumn(column interface{}) *Query
- func (query *Query) Clone() *Query
- func (query *Query) CopyAggregate() Aggregate
- func (query *Query) CopyBindings() map[string][]interface{}
- func (query *Query) CopyColumns() []interface{}
- func (query *Query) CopyDistinctColumns() []interface{}
- func (query *Query) CopyFrom() From
- func (query *Query) CopyGroups() []interface{}
- func (query *Query) CopyHavings() []Having
- func (query *Query) CopyJoins() []Join
- func (query *Query) CopyLock() interface{}
- func (query *Query) CopyOrders() []Order
- func (query *Query) CopyUnionOrders() []Order
- func (query *Query) CopyUnions() []Union
- func (query *Query) CopyWheres() []Where
- func (query *Query) GetBindings(key ...string) []interface{}
- type Quoter
- type Select
- type Table
- func (table *Table) AddCommand(name string, success func(), fail func(), params ...interface{})
- func (table *Table) GetColumn(name string) *Column
- func (table *Table) GetIndex(name string) *Index
- func (table *Table) GetName() string
- func (table *Table) GetPrimary(name string, columns ...*Column) *Primary
- func (table *Table) HasColumn(name string) bool
- func (table *Table) HasIndex(name string) bool
- func (table *Table) NewColumn(name string) *Column
- func (table *Table) NewIndex(name string, columns ...*Column) *Index
- func (table *Table) NewPrimary(name string, columns ...*Column) *Primary
- func (table *Table) PushColumn(column *Column) *Table
- func (table *Table) PushIndex(index *Index) *Table
- type Union
- type Version
- type Where
Constants ¶
This section is empty.
Variables ¶
View Source
var BindingKeys = []string{
"select", "from", "join", "where",
"groupBy", "having",
"order",
"union", "unionOrder",
"sql",
}
View Source
var Grammars = map[string]Grammar{}
View Source
var Operators = []string{
"=", "<", ">", "<=", ">=", "<>", "!=", "<=>",
"like", "like binary", "not like", "ilike",
"&", "|", "^", "<<", ">>",
"rlike", "not rlike", "regexp", "not regexp",
"~", "~*", "!~", "!~*", "similar to",
"not similar to", "not ilike", "~~*", "!~~*",
}
Functions ¶
func IsExpression ¶
func IsExpression(value interface{}) bool
Types ¶
type Column ¶
type Column struct { DBName string `db:"db_name"` TableName string `db:"table_name"` Name string `db:"name"` Position int `db:"position"` Default interface{} `db:"default"` DefaultRaw string `db:"default_raw"` Nullable bool `db:"nullable"` IsUnsigned bool `db:"unsigned"` Type string `db:"type"` Length *int `db:"length"` OctetLength *int `db:"octet_length"` Precision *int `db:"precision"` Scale *int `db:"scale"` DateTimePrecision *int `db:"datetime_precision"` Charset *string `db:"charset"` Collation *string `db:"collation"` Key *string `db:"key"` Extra *string `db:"extra"` Comment *string `db:"comment"` Primary bool `db:"primary"` TypeName string `db:"type_name"` MaxLength int DefaultLength int MaxPrecision int DefaultPrecision int MaxScale int DefaultScale int MaxDateTimePrecision int DefaultDateTimePrecision int Option []string Table *Table Indexes []*Index Constraint *Constraint }
type Connection ¶
type Constraint ¶
type Constraint struct { SchemaName string TableName string ColumnName string Type string Args []string Table *Table }
func NewConstraint ¶
func NewConstraint(schemaName string, tableName string, columnName string) *Constraint
type Expression ¶
type Expression struct {
Value interface{}
}
func NewExpression ¶
func NewExpression(value interface{}) Expression
func Raw ¶
func Raw(value interface{}) Expression
func (Expression) GetValue ¶
func (expression Expression) GetValue() string
type Grammar ¶
type Grammar interface { NewWith(db *sqlx.DB, config *Config, option *Option) (Grammar, error) NewWithRead(write *sqlx.DB, writeConfig *Config, read *sqlx.DB, readConfig *Config, option *Option) (Grammar, error) Wrap(value interface{}) string WrapTable(value interface{}) string OnConnected() error GetVersion() (*Version, error) GetDatabase() string GetSchema() string GetOperators() []string GetTables() ([]string, error) TableExists(name string) (bool, error) GetTable(name string) (*Table, error) CreateTable(table *Table) error AlterTable(table *Table) error DropTable(name string) error DropTableIfExists(name string) error RenameTable(old string, new string) error GetColumnListing(dbName string, tableName string) ([]*Column, error) CompileInsert(query *Query, columns []interface{}, values [][]interface{}) (string, []interface{}) CompileInsertOrIgnore(query *Query, columns []interface{}, values [][]interface{}) (string, []interface{}) CompileInsertGetID(query *Query, columns []interface{}, values [][]interface{}, sequence string) (string, []interface{}) CompileInsertUsing(query *Query, columns []interface{}, sql string) string CompileUpsert(query *Query, columns []interface{}, values [][]interface{}, uniqueBy []interface{}, updateValues interface{}) (string, []interface{}) CompileUpdate(query *Query, values map[string]interface{}) (string, []interface{}) CompileDelete(query *Query) (string, []interface{}) CompileTruncate(query *Query) ([]string, [][]interface{}) CompileSelect(query *Query) string CompileSelectOffset(query *Query, offset *int) string CompileExists(query *Query) string ProcessInsertGetID(sql string, bindings []interface{}, sequence string) (int64, error) }
type Index ¶
type Index struct { DBName string `db:"db_name"` TableName string `db:"table_name"` ColumnName string `db:"column_name"` Name string `db:"index_name"` SEQ int `db:"seq_in_index"` SeqColumn int `db:"seq_in_column"` Collation string `db:"collation"` Nullable bool `db:"nullable"` Unique bool `db:"unique"` Primary bool `db:"primary"` SubPart int `db:"sub_part"` Type string `db:"type"` IndexType string `db:"index_type"` Comment *string `db:"comment"` IndexComment *string `db:"index_comment"` Table *Table Columns []*Column }
type Query ¶
type Query struct { UseWriteConnection bool Lock interface{} From From Columns []interface{} Aggregate Aggregate Wheres []Where Joins []Join Unions []Union UnionLimit int UnionOffset int UnionOrders []Order Orders []Order Limit int Offset int Groups []interface{} Havings []Having Bindings map[string][]interface{} Distinct bool DistinctColumns []interface{} IsJoinClause bool BindingOffset int SQL string }
func (*Query) AddBinding ¶
func (*Query) CopyAggregate ¶
func (*Query) CopyBindings ¶
CopyBindings copy Bindings
func (*Query) CopyColumns ¶
func (query *Query) CopyColumns() []interface{}
func (*Query) CopyDistinctColumns ¶
func (query *Query) CopyDistinctColumns() []interface{}
func (*Query) CopyGroups ¶
func (query *Query) CopyGroups() []interface{}
func (*Query) CopyHavings ¶
func (*Query) CopyOrders ¶
func (*Query) CopyUnionOrders ¶
func (*Query) CopyUnions ¶
func (*Query) CopyWheres ¶
func (*Query) GetBindings ¶
type Quoter ¶
type Quoter interface { Bind(db *sqlx.DB, prefix string, dbRead ...*sqlx.DB) Quoter ID(value string) string VAL(value interface{}) string Wrap(value interface{}) string WrapTable(value interface{}) string WrapUnion(sql string) string IsExpression(value interface{}) bool Parameter(value interface{}, num int) string Parameterize(values []interface{}, offset int) string Columnize(columns []interface{}) string }
type Table ¶
type Table struct { DBName string `db:"db_name"` SchemaName string `db:"schema_name"` TableName string `db:"table_name"` Comment string `db:"table_comment"` Type string `db:"table_type"` Engine string `db:"engine"` CreateTime time.Time `db:"create_time"` CreateOptions string `db:"create_options"` Collation string `db:"collation"` Charset string `db:"charset"` Rows int `db:"table_rows"` RowLength int `db:"avg_row_length"` IndexLength int `db:"index_length"` AutoIncrement int `db:"auto_increment"` Primary *Primary ColumnMap map[string]*Column IndexMap map[string]*Index Columns []*Column Indexes []*Index Commands []*Command }
func (*Table) AddCommand ¶
func (*Table) PushColumn ¶
Click to show internal directories.
Click to hide internal directories.