Documentation ¶
Index ¶
- Constants
- Variables
- func Alias(e SqlExpr, name string) *alias
- func AsAddition(e SqlExpr) *addition
- func Comment(text string) *comment
- func ContextWithToggleMultiTable(ctx context.Context, v bool) context.Context
- func ContextWithToggleNeedAutoAlias(ctx context.Context, v bool) context.Context
- func ContextWithToggleUseValues(ctx context.Context, v bool) context.Context
- func ContextWithToggles(ctx context.Context, toggles Toggles) context.Context
- func CrossJoin(tar SqlExpr) *join
- func EachField(ctx context.Context, t typesx.Type, each func(*StructField) bool)
- func ForEachFieldValue(ctx context.Context, v interface{}, fn func(*FieldValue))
- func ForUpdate() *addition
- func FullJoin(tar SqlExpr) *join
- func GetColumnName(name, tag string) string
- func GroupBy(grps ...SqlExpr) *groupby
- func InnerJoin(tar SqlExpr) *join
- func IsNilExpr(e SqlExpr) bool
- func Join(tar SqlExpr, prefixes ...string) *join
- func LeftJoin(tar SqlExpr) *join
- func Limit(count int64) *limit
- func OnConflict(cols *Columns) *onconflict
- func OrderBy(orders ...*Order) *orderby
- func RightJoin(tar SqlExpr) *join
- func ScanDefToTable(tbl *Table, i interface{})
- func SplitIndexNameAndMethod(v string) (string, string)
- func TableAliasFromContext(ctx context.Context) (string, bool)
- func TableNameFromContext(ctx context.Context) (string, bool)
- func ToMap(lst []string) map[string]bool
- func Where(c SqlCondition) *where
- func WithTabelAlias(tbl string) func(ctx context.Context) context.Context
- func WithTableName(tbl string) func(ctx context.Context) context.Context
- func WriteAdditions(e *Ex, adds ...Addition)
- func WriteAssignments(e *Ex, assignments ...*Assignment)
- type Addition
- type AdditionType
- type Additions
- type Assignment
- type AssignmentMarker
- type Assignments
- type Column
- func (c *Column) Between(l, r interface{}) SqlCondition
- func (c *Column) Dec(d int) SqlExpr
- func (c *Column) Eq(v interface{}) SqlCondition
- func (c *Column) Ex(ctx context.Context) *Ex
- func (c *Column) Expr(query string, args ...interface{}) *Ex
- func (c Column) Field(name string) *Column
- func (c *Column) Gt(v interface{}) SqlCondition
- func (c *Column) Gte(v interface{}) SqlCondition
- func (c *Column) In(args ...interface{}) SqlCondition
- func (c *Column) Inc(d int) SqlExpr
- func (c *Column) IsNil() bool
- func (c *Column) IsNotNull() SqlCondition
- func (c *Column) IsNull() SqlCondition
- func (c *Column) LLike(v string) SqlCondition
- func (c *Column) Like(v string) SqlCondition
- func (c *Column) Lt(v interface{}) SqlCondition
- func (c *Column) Lte(v interface{}) SqlCondition
- func (c *Column) Neq(v interface{}) SqlCondition
- func (c *Column) NotBetween(l, r interface{}) SqlCondition
- func (c *Column) NotIn(args ...interface{}) SqlCondition
- func (c *Column) NotLike(v string) SqlCondition
- func (c Column) Of(t *Table) *Column
- func (c Column) On(t *Table) *Column
- func (c *Column) RLike(v string) SqlCondition
- func (c *Column) T() *Table
- func (c Column) Type(v interface{}, tag string) *Column
- func (c *Column) ValueBy(v interface{}) *Assignment
- type ColumnType
- type Columns
- func (c *Columns) Add(cols ...*Column)
- func (c *Columns) AutoIncrement() *Column
- func (c *Columns) Clone() *Columns
- func (c *Columns) Col(name string) *Column
- func (c *Columns) ColByFieldName(name string) *Column
- func (c *Columns) ColNames() []string
- func (c *Columns) Cols(names ...string) (*Columns, error)
- func (c *Columns) ColsByFieldNames(names ...string) (*Columns, error)
- func (c *Columns) Ex(ctx context.Context) *Ex
- func (c *Columns) FieldNames() []string
- func (c *Columns) IsNil() bool
- func (c *Columns) Len() int
- func (c *Columns) List() []*Column
- func (c *Columns) MustCols(names ...string) *Columns
- func (c *Columns) MustColsByFieldNames(names ...string) *Columns
- func (c *Columns) Range(f func(*Column, int))
- type CondCompose
- type Condition
- type DataTypeDescriber
- type DeprecatedActs
- 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) Ex(ctx context.Context) *Ex
- func (e *Ex) Grow(n int)
- func (e *Ex) IsNil() bool
- func (e *Ex) Query() string
- func (e *Ex) SetExactly(exactly bool)
- func (e *Ex) WriteComments(comments []byte)
- func (e *Ex) WriteEnd()
- func (e *Ex) WriteExpr(expr SqlExpr)
- func (e *Ex) WriteGroup(f func(e *Ex))
- func (e *Ex) WriteHolder(idx int)
- func (e *Ex) WriteQuery(query string)
- func (e *Ex) WriteQueryByte(b byte)
- func (e *Ex) WriteQueryRune(r rune)
- type FieldValue
- type FieldValues
- type FieldsFactory
- type Function
- func Avg(es ...SqlExpr) *Function
- func Count(es ...SqlExpr) *Function
- func Distinct(es ...SqlExpr) *Function
- func First(es ...SqlExpr) *Function
- func Func(name string, es ...SqlExpr) *Function
- func Last(es ...SqlExpr) *Function
- func Max(es ...SqlExpr) *Function
- func Min(es ...SqlExpr) *Function
- func Sum(es ...SqlExpr) *Function
- type IndexDef
- type IndexDefine
- type Indexes
- type Key
- type Keys
- type Model
- type Order
- type SelectStatement
- type SqlAssignment
- type SqlCondition
- type SqlConditionMarker
- type SqlExpr
- type StmtDelete
- type StmtInsert
- type StmtSelect
- type StmtUpdate
- type StructField
- type Table
- func (t *Table) AddCol(c *Column)
- func (t *Table) AddKey(k *Key)
- func (t *Table) AssignmentsByFieldValues(fvs FieldValues) Assignments
- func (t *Table) ColumnsAndValuesByFieldValues(fvs FieldValues) (*Columns, []interface{})
- func (t *Table) Diff(prevT *Table, d Dialect) (exprList []SqlExpr)
- func (t *Table) Ex(ctx context.Context) *Ex
- func (t *Table) Expr(query string, args ...interface{}) *Ex
- func (t *Table) IsNil() bool
- func (t *Table) TableName() string
- func (t Table) WithSchema(schema string) *Table
- type TableDefinition
- type Tables
- type Toggles
- type ValueExpr
- type WithColDesc
- type WithColRel
- type WithComments
- type WithIndexes
- type WithPrimaryKey
- type WithTableDesc
- type WithUniqueIndexes
Constants ¶
View Source
const ( ToggleNeedAutoAlias = "NeedAlias" ToggleMultiTable = "MultiTable" ToggleUseValues = "UseValues" )
Variables ¶
Functions ¶
func AsAddition ¶
func AsAddition(e SqlExpr) *addition
func ContextWithToggles ¶
func ForEachFieldValue ¶
func ForEachFieldValue(ctx context.Context, v interface{}, fn func(*FieldValue))
func GetColumnName ¶
func OnConflict ¶
func OnConflict(cols *Columns) *onconflict
func ScanDefToTable ¶
func ScanDefToTable(tbl *Table, i interface{})
func SplitIndexNameAndMethod ¶
SplitIndexNameAndMethod @def index name/method
func Where ¶
func Where(c SqlCondition) *where
func WriteAdditions ¶
func WriteAssignments ¶
func WriteAssignments(e *Ex, assignments ...*Assignment)
Types ¶
type Addition ¶
type Addition interface { SqlExpr AdditionKind() AdditionType }
type AdditionType ¶
type AdditionType int
const ( AdditionJoin AdditionType = iota AdditionWhere AdditionGroupBy AdditionCombination AdditionOrderBy AdditionLimit AdditionOnConflict AdditionOther AdditionComment )
func (AdditionType) AdditionKind ¶
func (t AdditionType) AdditionKind() AdditionType
type Assignment ¶
type Assignment struct { AssignmentMarker // contains filtered or unexported fields }
func ColumnsAndValues ¶
func ColumnsAndValues(columns SqlExpr, values ...interface{}) *Assignment
func (*Assignment) IsNil ¶
func (a *Assignment) IsNil() bool
type AssignmentMarker ¶
type AssignmentMarker interface {
// contains filtered or unexported methods
}
type Assignments ¶
type Assignments []*Assignment
type Column ¶
type Column struct { Name string FieldName string Table *Table *ColumnType // contains filtered or unexported fields }
func (*Column) Between ¶
func (c *Column) Between(l, r interface{}) SqlCondition
func (*Column) Eq ¶
func (c *Column) Eq(v interface{}) SqlCondition
func (*Column) Gt ¶
func (c *Column) Gt(v interface{}) SqlCondition
func (*Column) Gte ¶
func (c *Column) Gte(v interface{}) SqlCondition
func (*Column) In ¶
func (c *Column) In(args ...interface{}) SqlCondition
func (*Column) IsNotNull ¶
func (c *Column) IsNotNull() SqlCondition
func (*Column) IsNull ¶
func (c *Column) IsNull() SqlCondition
func (*Column) LLike ¶
func (c *Column) LLike(v string) SqlCondition
func (*Column) Like ¶
func (c *Column) Like(v string) SqlCondition
func (*Column) Lt ¶
func (c *Column) Lt(v interface{}) SqlCondition
func (*Column) Lte ¶
func (c *Column) Lte(v interface{}) SqlCondition
func (*Column) Neq ¶
func (c *Column) Neq(v interface{}) SqlCondition
func (*Column) NotBetween ¶
func (c *Column) NotBetween(l, r interface{}) SqlCondition
func (*Column) NotIn ¶
func (c *Column) NotIn(args ...interface{}) SqlCondition
func (*Column) NotLike ¶
func (c *Column) NotLike(v string) SqlCondition
func (*Column) RLike ¶
func (c *Column) RLike(v string) SqlCondition
func (*Column) ValueBy ¶
func (c *Column) ValueBy(v interface{}) *Assignment
type ColumnType ¶
type ColumnType struct { Type typesx.Type DataType string Length uint64 Decimal uint64 Default *string OnUpdate *string Null bool AutoIncrement bool Comment string Desc []string Rel []string DeprecatedActs *DeprecatedActs }
func AnalyzeColumnType ¶
func AnalyzeColumnType(t typesx.Type, tag string) *ColumnType
type Columns ¶
type Columns struct {
// contains filtered or unexported fields
}
func (*Columns) AutoIncrement ¶
func (*Columns) ColByFieldName ¶
func (*Columns) ColsByFieldNames ¶
func (*Columns) FieldNames ¶
func (*Columns) MustColsByFieldNames ¶
type CondCompose ¶
type CondCompose struct { SqlConditionMarker // contains filtered or unexported fields }
func ComposeConditions ¶
func ComposeConditions(op string, conds ...SqlCondition) *CondCompose
func (*CondCompose) And ¶
func (c *CondCompose) And(cond SqlCondition) SqlCondition
func (*CondCompose) IsNil ¶
func (c *CondCompose) IsNil() bool
func (*CondCompose) Or ¶
func (c *CondCompose) Or(cond SqlCondition) SqlCondition
func (*CondCompose) Xor ¶
func (c *CondCompose) Xor(cond SqlCondition) SqlCondition
type Condition ¶
type Condition struct { SqlConditionMarker // contains filtered or unexported fields }
func (*Condition) And ¶
func (c *Condition) And(cond SqlCondition) SqlCondition
func (*Condition) Or ¶
func (c *Condition) Or(cond SqlCondition) SqlCondition
func (*Condition) Xor ¶
func (c *Condition) Xor(cond SqlCondition) SqlCondition
type DataTypeDescriber ¶
type DeprecatedActs ¶
type DeprecatedActs struct {
RenameTo string `name:"rename"`
}
type Dialect ¶
type Dialect interface { DriverName() string PrimaryKeyName() string IsErrorUnknownDatabase(error) bool IsErrorConflict(error) bool CreateDatabase(string) SqlExpr CreateSchema(string) SqlExpr DropDatabase(string) SqlExpr CreateTableIsNotExists(t *Table) []SqlExpr DropTable(*Table) SqlExpr TruncateTable(*Table) SqlExpr AddColumn(*Column) SqlExpr RenameColumn(*Column, *Column) SqlExpr ModifyColumn(*Column, *Column) SqlExpr DropColumn(*Column) SqlExpr AddIndex(*Key) SqlExpr DropIndex(*Key) SqlExpr DataType(*ColumnType) SqlExpr }
type Ex ¶
type Ex struct {
// contains filtered or unexported fields
}
func ColumnsByStruct ¶
func ColumnsByStruct(v interface{}) *Ex
func ExactlyExpr ¶
func ResolveExpr ¶
func ResolveExpr(v interface{}) *Ex
func ResolveExprContext ¶
func (*Ex) AppendArgs ¶
func (e *Ex) AppendArgs(args ...interface{})
func (*Ex) SetExactly ¶
func (*Ex) WriteComments ¶
func (*Ex) WriteGroup ¶
func (*Ex) WriteHolder ¶
func (*Ex) WriteQuery ¶
func (*Ex) WriteQueryByte ¶
func (*Ex) WriteQueryRune ¶
type FieldValue ¶
type FieldValue struct { Field StructField TableName string Value reflect.Value }
type FieldValues ¶
type FieldValues map[string]interface{}
func FieldValueFromStruct ¶
func FieldValueFromStruct(v interface{}, names []string) FieldValues
func FieldValueFromStructByNoneZero ¶
func FieldValueFromStructByNoneZero(v interface{}, excludes ...string) FieldValues
type FieldsFactory ¶
type FieldsFactory struct {
// contains filtered or unexported fields
}
func (*FieldsFactory) TableFieldsFor ¶
func (ft *FieldsFactory) TableFieldsFor(ctx context.Context, t typesx.Type) []*StructField
type IndexDefine ¶
func ParseIndexDefine ¶
func ParseIndexDefine(def string) *IndexDefine
func (IndexDefine) ID ¶
func (i IndexDefine) ID() string
type Key ¶
func PrimaryKey ¶
type SelectStatement ¶
type SelectStatement interface { SqlExpr // contains filtered or unexported methods }
type SqlAssignment ¶
type SqlAssignment interface { SqlExpr AssignmentMarker }
type SqlCondition ¶
type SqlCondition interface { SqlExpr SqlConditionMarker And(SqlCondition) SqlCondition Or(SqlCondition) SqlCondition Xor(SqlCondition) SqlCondition }
var EmptyCondition SqlCondition = (*Condition)(nil)
func And ¶
func And(conds ...SqlCondition) SqlCondition
func Or ¶
func Or(conds ...SqlCondition) SqlCondition
func Xor ¶
func Xor(conds ...SqlCondition) SqlCondition
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) From ¶
func (s StmtDelete) From(tbl *Table, adds ...Addition) *StmtDelete
func (*StmtDelete) IsNil ¶
func (s *StmtDelete) IsNil() bool
type StmtInsert ¶
type StmtInsert struct {
// contains filtered or unexported fields
}
func Insert ¶
func Insert(modifiers ...string) *StmtInsert
func (StmtInsert) Into ¶
func (s StmtInsert) Into(tbl *Table, adds ...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 { SelectStatement // contains filtered or unexported fields }
func Select ¶
func Select(e SqlExpr, modifiers ...string) *StmtSelect
func (StmtSelect) From ¶
func (s StmtSelect) From(tbl *Table, adds ...Addition) *StmtSelect
func (*StmtSelect) IsNil ¶
func (s *StmtSelect) IsNil() bool
type StmtUpdate ¶
type StmtUpdate struct {
// contains filtered or unexported fields
}
func Update ¶
func Update(tbl *Table, modifiers ...string) *StmtUpdate
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 SqlCondition, adds ...Addition) *StmtUpdate
type StructField ¶
type StructField struct { Name string FieldName string Type typesx.Type Field typesx.StructField Tags map[string]reflectx.StructTag Loc []int ModelLoc []int ColumnType ColumnType }
func StructFieldsFor ¶
func StructFieldsFor(ctx context.Context, t typesx.Type) []*StructField
func (*StructField) FieldModelValue ¶
func (sf *StructField) FieldModelValue(v reflect.Value) reflect.Value
func (*StructField) FieldValue ¶
func (sf *StructField) FieldValue(v reflect.Value) reflect.Value
type Table ¶
type Table struct { Name string Desc []string Schema string ModelName string Model Model Columns Keys }
func T ¶
func T(tblName string, defs ...TableDefinition) *Table
func TableFromModel ¶
func (*Table) AssignmentsByFieldValues ¶
func (t *Table) AssignmentsByFieldValues(fvs FieldValues) Assignments
func (*Table) ColumnsAndValuesByFieldValues ¶
func (t *Table) ColumnsAndValuesByFieldValues(fvs FieldValues) (*Columns, []interface{})
func (Table) WithSchema ¶
type TableDefinition ¶
type TableDefinition interface{ T() *Table }
type Tables ¶
type Tables struct {
// contains filtered or unexported fields
}
func (*Tables) TableNames ¶
type Toggles ¶
func TogglesFromContext ¶
type WithColDesc ¶
type WithColRel ¶
type WithComments ¶
type WithIndexes ¶
type WithIndexes interface {
Indexes() Indexes
}
type WithPrimaryKey ¶
type WithPrimaryKey interface {
PrimaryKey() []string
}
type WithTableDesc ¶
type WithTableDesc interface {
TableDesc() []string
}
type WithUniqueIndexes ¶
type WithUniqueIndexes interface {
UniqueIndexes() Indexes
}
Source Files ¶
- builder.go
- builder_addition.go
- builder_addition_comment.go
- builder_addition_groupby.go
- builder_addition_join.go
- builder_addition_limit.go
- builder_addition_onconflict.go
- builder_addition_orderby.go
- builder_addition_other.go
- builder_addition_where.go
- builder_alias.go
- builder_assignment.go
- builder_condition.go
- builder_def_col.go
- builder_def_col_type.go
- builder_def_cols.go
- builder_def_key.go
- builder_def_tab.go
- builder_expr.go
- builder_expr_by.go
- builder_function.go
- builder_stmt_delete.go
- builder_stmt_insert.go
- builder_stmt_select.go
- builder_stmt_update.go
- builder_stmt_with.go
- builder_toggle.go
- builder_util.go
Click to show internal directories.
Click to hide internal directories.