Documentation ¶
Index ¶
- Variables
- func AsAddition(expr SqlExpr) *otherAddition
- func AscOrder(expr SqlExpr) *order
- func Comment(c string) comment
- func DescOrder(expr SqlExpr) *order
- func ForEachStructFieldValue(rv reflect.Value, ...)
- func ForUpdate() *otherAddition
- func GetColumnName(fieldName, tagValue string) string
- func GroupBy(groups ...SqlExpr) *groupBy
- func Limit(rowCount int64) *limit
- func OnConflict(columns *Columns) *onConflict
- func OnDuplicateKeyUpdate(assignments ...*Assignment) *otherAddition
- func OrderBy(orders ...*order) *orderBy
- func ResolveIndexNameAndMethod(n string) (name string, method string)
- func Returning(expr SqlExpr) *otherAddition
- func ScanDefToTable(rv reflect.Value, table *Table)
- func ToMap(list []string) map[string]bool
- func Where(c SqlCondition) *where
- type Addition
- type Additions
- type AliasEx
- type Assignment
- type Assignments
- type Column
- func (c *Column) Between(leftValue interface{}, rightValue interface{}) *Condition
- func (c *Column) Desc(d int) *Ex
- func (c *Column) Eq(v interface{}) *Condition
- func (c *Column) Ex(query string, args ...interface{}) *Ex
- func (c *Column) Expr() *Ex
- func (c Column) Field(fieldName string) *Column
- func (c *Column) Gt(v interface{}) *Condition
- func (c *Column) Gte(v interface{}) *Condition
- func (c *Column) In(args ...interface{}) *Condition
- func (c *Column) Incr(d int) *Ex
- func (c *Column) IsNil() bool
- func (c *Column) IsNotNull() *Condition
- func (c *Column) IsNull() *Condition
- func (c *Column) LeftLike(v string) *Condition
- func (c *Column) Like(v string) *Condition
- func (c *Column) Lt(v interface{}) *Condition
- func (c *Column) Lte(v interface{}) *Condition
- func (c *Column) Neq(v interface{}) *Condition
- func (c *Column) NotBetween(leftValue interface{}, rightValue interface{}) *Condition
- func (c *Column) NotIn(args ...interface{}) *Condition
- func (c *Column) NotLike(v string) *Condition
- func (c *Column) Of(table *Table) *Column
- func (c Column) On(table *Table) *Column
- func (c *Column) RightLike(v string) *Condition
- func (c *Column) T() *Table
- func (c Column) Type(v interface{}, tagValue string) *Column
- func (c *Column) ValueBy(v interface{}) *Assignment
- type ColumnType
- type Columns
- func (cols *Columns) Add(columns ...*Column)
- func (cols *Columns) AutoIncrement() (col *Column)
- func (cols *Columns) Clone() *Columns
- func (cols *Columns) Col(columnName string) (col *Column)
- func (cols *Columns) Cols(colNames ...string) (*Columns, error)
- func (cols *Columns) Expr() *Ex
- func (cols *Columns) F(fileName string) (col *Column)
- func (cols *Columns) FieldNames() []string
- func (cols *Columns) Fields(fieldNames ...string) (*Columns, error)
- func (cols *Columns) IsNil() bool
- func (cols *Columns) Len() int
- func (cols *Columns) List() (l []*Column)
- func (cols *Columns) Range(cb func(col *Column, idx int))
- func (cols *Columns) Remove(name string)
- type CondRule
- type CondRules
- type Condition
- type DataTypeDescriber
- type Dialect
- type Ex
- func (e *Ex) AppendArgs(args ...interface{})
- func (e *Ex) Args() []interface{}
- func (e *Ex) ArgsLen() int
- func (e *Ex) Err() error
- func (e *Ex) Expr() *Ex
- func (e *Ex) Flatten() *Ex
- func (e *Ex) IsNil() bool
- func (e *Ex) Query() string
- func (e *Ex) ReplaceValueHolder(bindVar func(idx int) string) *Ex
- func (e *Ex) WhiteComments(comments string)
- func (e *Ex) WriteEnd()
- func (e *Ex) WriteExpr(expr SqlExpr)
- func (e *Ex) WriteGroup(fn func(e *Ex))
- func (e *Ex) WriteHolder(idx int)
- type FieldValues
- type Function
- func Avg(sqlExprs ...SqlExpr) *Function
- func Count(sqlExprs ...SqlExpr) *Function
- func Distinct(sqlExprs ...SqlExpr) *Function
- func First(sqlExprs ...SqlExpr) *Function
- func Func(name string, sqlExprs ...SqlExpr) *Function
- func Last(sqlExprs ...SqlExpr) *Function
- func Max(sqlExprs ...SqlExpr) *Function
- func Min(sqlExprs ...SqlExpr) *Function
- func Sum(sqlExprs ...SqlExpr) *Function
- type Indexes
- type Key
- type Keys
- type Model
- type SqlAssignment
- type SqlAssignmentMarker
- type SqlCondition
- type SqlConditionMarker
- type SqlExpr
- type StmtDelete
- type StmtInsert
- type StmtSelect
- type StmtUpdate
- type Table
- func (t *Table) AddCol(d *Column)
- func (t *Table) AddKey(key *Key)
- func (t *Table) AssignmentsByFieldValues(fieldValues FieldValues) (assignments Assignments)
- func (t *Table) ColumnsAndValuesByFieldValues(fieldValues FieldValues) (columns *Columns, args []interface{})
- func (t *Table) Diff(prevTable *Table, dialect Dialect, skipDropColumn bool) (exprList []SqlExpr)
- func (t *Table) Ex(query string, args ...interface{}) *Ex
- func (t *Table) Expr() *Ex
- func (t *Table) IsNil() bool
- func (t Table) WithSchema(schema string) *Table
- type TableDefinition
- type Tables
- type ValuerExpr
- type WithComments
- type WithIndexes
- type WithPrimaryKey
- type WithUniqueIndexes
Constants ¶
This section is empty.
Variables ¶
View Source
var (
UpdateNeedLimitByWhere = errors.New("no where limit for update")
)
Functions ¶
func AsAddition ¶
func AsAddition(expr SqlExpr) *otherAddition
func ForEachStructFieldValue ¶
func GetColumnName ¶
func OnConflict ¶
func OnConflict(columns *Columns) *onConflict
func OnDuplicateKeyUpdate ¶
func OnDuplicateKeyUpdate(assignments ...*Assignment) *otherAddition
func ScanDefToTable ¶
func Where ¶
func Where(c SqlCondition) *where
Types ¶
type Assignment ¶
type Assignment struct { SqlExpr SqlAssignmentMarker }
func AsAssignment ¶
func AsAssignment(ex SqlExpr) *Assignment
func ColumnsAndValues ¶
func ColumnsAndValues(cols *Columns, values ...interface{}) *Assignment
func (*Assignment) IsNil ¶
func (a *Assignment) IsNil() bool
type Assignments ¶
type Assignments []*Assignment
func (Assignments) Expr ¶
func (assigns Assignments) Expr() *Ex
func (Assignments) IsNil ¶
func (assigns Assignments) IsNil() bool
type Column ¶
type Column struct { Name string FieldName string Table *Table Exactly bool *ColumnType }
func (*Column) NotBetween ¶
func (*Column) ValueBy ¶
func (c *Column) ValueBy(v interface{}) *Assignment
type ColumnType ¶
type ColumnType struct { Type reflect.Type GetDataType func(engine string) string Length uint64 Decimal uint64 Default *string Null bool AutoIncrement bool Comment string }
func ColumnTypeFromTypeAndTag ¶
func ColumnTypeFromTypeAndTag(typ reflect.Type, nameAndFlags string) *ColumnType
type Columns ¶
type Columns struct {
// contains filtered or unexported fields
}
func (*Columns) AutoIncrement ¶
func (*Columns) FieldNames ¶
type CondRules ¶
type CondRules struct { SqlConditionMarker // contains filtered or unexported fields }
func NewCondRules ¶
func NewCondRules() *CondRules
type Condition ¶
type Condition struct { SqlExpr SqlConditionMarker }
func And ¶
func And(condList ...SqlCondition) *Condition
func Or ¶
func Or(condList ...SqlCondition) *Condition
func Xor ¶
func Xor(condList ...SqlCondition) *Condition
func (Condition) And ¶
func (c Condition) And(cond SqlCondition) *Condition
func (Condition) Or ¶
func (c Condition) Or(cond SqlCondition) *Condition
func (Condition) Xor ¶
func (c Condition) Xor(cond SqlCondition) *Condition
type DataTypeDescriber ¶
type Dialect ¶
type Dialect interface { DriverName() string BindVar(i int) string PrimaryKeyName() string IsErrorUnknownDatabase(err error) bool IsErrorConflict(err error) bool CreateDatabase(dbName string) SqlExpr CreateSchema(schemaName string) SqlExpr DropDatabase(dbName string) SqlExpr CreateTableIsNotExists(t *Table) []SqlExpr DropTable(t *Table) SqlExpr TruncateTable(t *Table) SqlExpr AddColumn(col *Column) SqlExpr ModifyColumn(col *Column) SqlExpr DropColumn(col *Column) SqlExpr AddIndex(key *Key) SqlExpr DropIndex(key *Key) SqlExpr DataType(columnType *ColumnType) SqlExpr }
type Ex ¶
func (*Ex) AppendArgs ¶
func (e *Ex) AppendArgs(args ...interface{})
func (*Ex) WhiteComments ¶
func (*Ex) WriteGroup ¶
func (*Ex) WriteHolder ¶
type FieldValues ¶
type FieldValues map[string]interface{}
func FieldValuesFromStructBy ¶
func FieldValuesFromStructBy(structValue interface{}, fieldNames []string) (fieldValues FieldValues)
func FieldValuesFromStructByNonZero ¶
func FieldValuesFromStructByNonZero(structValue interface{}, excludes ...string) (fieldValues FieldValues)
type SqlAssignment ¶
type SqlAssignment interface { SqlExpr SqlAssignmentMarker }
type SqlAssignmentMarker ¶
type SqlAssignmentMarker interface {
// contains filtered or unexported methods
}
type SqlCondition ¶
type SqlCondition interface { SqlExpr SqlConditionMarker }
type SqlConditionMarker ¶
type SqlConditionMarker interface {
// contains filtered or unexported methods
}
type StmtDelete ¶
type StmtDelete struct {
// contains filtered or unexported fields
}
func Delete ¶
func Delete() *StmtDelete
func (*StmtDelete) Expr ¶
func (s *StmtDelete) Expr() *Ex
func (StmtDelete) From ¶
func (s StmtDelete) From(table *Table, additions ...Addition) *StmtDelete
func (*StmtDelete) IsNil ¶
func (s *StmtDelete) IsNil() bool
type StmtInsert ¶
type StmtInsert struct {
// contains filtered or unexported fields
}
https://dev.mysql.com/doc/refman/5.6/en/insert.html
func Insert ¶
func Insert(modifiers ...string) *StmtInsert
func (*StmtInsert) Expr ¶
func (s *StmtInsert) Expr() *Ex
func (StmtInsert) Into ¶
func (s StmtInsert) Into(table *Table, additions ...Addition) *StmtInsert
func (*StmtInsert) IsNil ¶
func (s *StmtInsert) IsNil() bool
func (StmtInsert) Values ¶
func (s StmtInsert) Values(cols *Columns, values ...interface{}) *StmtInsert
type StmtSelect ¶
type StmtSelect struct {
// contains filtered or unexported fields
}
func Select ¶
func Select(sqlExpr SqlExpr, modifiers ...string) *StmtSelect
func (*StmtSelect) Expr ¶
func (s *StmtSelect) Expr() *Ex
func (StmtSelect) From ¶
func (s StmtSelect) From(table *Table, additions ...Addition) *StmtSelect
func (*StmtSelect) IsNil ¶
func (s *StmtSelect) IsNil() bool
type StmtUpdate ¶
type StmtUpdate struct {
// contains filtered or unexported fields
}
func Update ¶
func Update(table *Table, modifiers ...string) *StmtUpdate
func (*StmtUpdate) Expr ¶
func (s *StmtUpdate) Expr() *Ex
func (*StmtUpdate) IsNil ¶
func (s *StmtUpdate) IsNil() bool
func (StmtUpdate) Set ¶
func (s StmtUpdate) Set(assignments ...*Assignment) *StmtUpdate
func (StmtUpdate) Where ¶
func (s StmtUpdate) Where(c *Condition, additions ...Addition) *StmtUpdate
type Table ¶
func T ¶
func T(tableName string, tableDefinitions ...TableDefinition) *Table
func (*Table) AssignmentsByFieldValues ¶
func (t *Table) AssignmentsByFieldValues(fieldValues FieldValues) (assignments Assignments)
func (*Table) ColumnsAndValuesByFieldValues ¶
func (t *Table) ColumnsAndValuesByFieldValues(fieldValues FieldValues) (columns *Columns, args []interface{})
func (Table) WithSchema ¶ added in v2.2.0
type TableDefinition ¶
type TableDefinition interface {
T() *Table
}
type Tables ¶
func (Tables) TableNames ¶
type ValuerExpr ¶
type ValuerExpr interface {
ValueEx() string
}
replace ? as some query snippet
examples: ? => ST_GeomFromText(?)
type WithComments ¶
type WithIndexes ¶
type WithIndexes interface {
Indexes() Indexes
}
type WithPrimaryKey ¶
type WithPrimaryKey interface {
PrimaryKey() []string
}
type WithUniqueIndexes ¶
type WithUniqueIndexes interface {
UniqueIndexes() Indexes
}
Click to show internal directories.
Click to hide internal directories.