Documentation ¶
Index ¶
- Variables
- func IsIDConditionWithNoTableErr(err error) bool
- type ErrIDConditionWithNoTable
- type ErrUnsupportedExprType
- type Statement
- func (statement *Statement) Alias(alias string) *Statement
- func (statement *Statement) AllCols() *Statement
- func (statement *Statement) And(query interface{}, args ...interface{}) *Statement
- func (statement *Statement) Asc(colNames ...string) *Statement
- func (statement *Statement) BuildConds(table *schemas.Table, bean interface{}, includeVersion bool, ...) (builder.Cond, error)
- func (statement *Statement) BuildUpdates(tableValue reflect.Value, ...) ([]string, []interface{}, error)
- func (statement *Statement) Cols(columns ...string) *Statement
- func (statement *Statement) ColumnStr() string
- func (statement *Statement) CondDeleted(col *schemas.Column) builder.Cond
- func (statement *Statement) Conds() builder.Cond
- func (statement *Statement) ConvertIDSQL(sqlStr string) string
- func (statement *Statement) ConvertSQLOrArgs(sqlOrArgs ...interface{}) (string, []interface{}, error)
- func (statement *Statement) ConvertUpdateSQL(sqlStr string) (string, string)
- func (statement *Statement) Decr(column string, arg ...interface{}) *Statement
- func (statement *Statement) Desc(colNames ...string) *Statement
- func (statement *Statement) Distinct(columns ...string) *Statement
- func (statement *Statement) ForUpdate() *Statement
- func (statement *Statement) GenCondSQL(condOrBuilder interface{}) (string, []interface{}, error)
- func (statement *Statement) GenConds(bean interface{}) (string, []interface{}, error)
- func (statement *Statement) GenCountSQL(beans ...interface{}) (string, []interface{}, error)
- func (statement *Statement) GenCreateTableSQL() []string
- func (statement *Statement) GenDelIndexSQL() []string
- func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interface{}, error)
- func (statement *Statement) GenFindSQL(autoCond builder.Cond) (string, []interface{}, error)
- func (statement *Statement) GenGetSQL(bean interface{}) (string, []interface{}, error)
- func (statement *Statement) GenIndexSQL() []string
- func (statement *Statement) GenInsertMapSQL(columns []string, args []interface{}) (string, []interface{}, error)
- func (statement *Statement) GenInsertSQL(colNames []string, args []interface{}) (string, []interface{}, error)
- func (statement *Statement) GenQuerySQL(sqlOrArgs ...interface{}) (string, []interface{}, error)
- func (statement *Statement) GenRawSQL() string
- func (statement *Statement) GenSumSQL(bean interface{}, columns ...string) (string, []interface{}, error)
- func (statement *Statement) GenUniqueSQL() []string
- func (statement *Statement) GetUnscoped() bool
- func (statement *Statement) GroupBy(keys string) *Statement
- func (statement *Statement) Having(conditions string) *Statement
- func (statement *Statement) ID(id interface{}) *Statement
- func (statement *Statement) In(column string, args ...interface{}) *Statement
- func (statement *Statement) Incr(column string, arg ...interface{}) *Statement
- func (statement *Statement) Join(joinOP string, tablename interface{}, condition string, args ...interface{}) *Statement
- func (statement *Statement) Limit(limit int, start ...int) *Statement
- func (statement *Statement) MustCols(columns ...string) *Statement
- func (statement *Statement) NotIn(column string, args ...interface{}) *Statement
- func (statement *Statement) Nullable(columns ...string)
- func (statement *Statement) Omit(columns ...string)
- func (statement *Statement) OmitConditions(columns ...string) *Statement
- func (statement *Statement) Or(query interface{}, args ...interface{}) *Statement
- func (statement *Statement) OrderBy(order string) *Statement
- func (statement *Statement) ProcessIDParam() error
- func (statement *Statement) ReplaceQuote(sql string) string
- func (statement *Statement) Reset()
- func (statement *Statement) SQL(query interface{}, args ...interface{}) *Statement
- func (statement *Statement) Select(str string) *Statement
- func (statement *Statement) SetContextCache(ctxCache contexts.ContextCache)
- func (statement *Statement) SetExpr(column string, expression interface{}) *Statement
- func (statement *Statement) SetNoAutoCondition(no ...bool) *Statement
- func (statement *Statement) SetRefBean(bean interface{}) error
- func (statement *Statement) SetRefValue(v reflect.Value) error
- func (statement *Statement) SetTable(tableNameOrBean interface{}) error
- func (statement *Statement) SetTableName(tableName string)
- func (statement *Statement) SetUnscoped() *Statement
- func (statement *Statement) TableName() string
- func (statement *Statement) Top(limit int) *Statement
- func (statement *Statement) UseBool(columns ...string) *Statement
- func (statement *Statement) Value2Interface(col *schemas.Column, fieldValue reflect.Value) (interface{}, error)
- func (statement *Statement) Where(query interface{}, args ...interface{}) *Statement
- func (statement *Statement) WriteArg(w *builder.BytesWriter, arg interface{}) error
- func (statement *Statement) WriteArgs(w *builder.BytesWriter, args []interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConditionType condition type unsupported ErrConditionType = errors.New("Unsupported condition type") // ErrUnSupportedSQLType parameter of SQL is not supported ErrUnSupportedSQLType = errors.New("Unsupported sql type") // ErrUnSupportedType unsupported error ErrUnSupportedType = errors.New("Unsupported type error") // ErrTableNotFound table not found error ErrTableNotFound = errors.New("Table not found") )
Functions ¶
func IsIDConditionWithNoTableErr ¶
IsIDConditionWithNoTableErr return true if the err is ErrIDConditionWithNoTable
Types ¶
type ErrIDConditionWithNoTable ¶
ErrIDConditionWithNoTable represents an error there is no reference table with an ID condition
func (ErrIDConditionWithNoTable) Error ¶
func (err ErrIDConditionWithNoTable) Error() string
type ErrUnsupportedExprType ¶
type ErrUnsupportedExprType struct {
// contains filtered or unexported fields
}
func (ErrUnsupportedExprType) Error ¶
func (err ErrUnsupportedExprType) Error() string
type Statement ¶
type Statement struct { RefTable *schemas.Table Start int LimitN *int OrderStr string JoinStr string GroupByStr string HavingStr string SelectStr string AltTableName string RawSQL string RawParams []interface{} UseCascade bool UseAutoJoin bool StoreEngine string Charset string UseCache bool UseAutoTime bool NoAutoCondition bool IsDistinct bool IsForUpdate bool TableAlias string CheckVersion bool ColumnMap columnMap OmitColumnMap columnMap OmitConditionMap columnMap MustColumnMap map[string]bool NullableMap map[string]bool IncrColumns exprParams DecrColumns exprParams ExprColumns exprParams BufferSize int Context contexts.ContextCache LastError error // contains filtered or unexported fields }
Statement save all the sql info for executing SQL
func NewStatement ¶
func NewStatement(dialect dialects.Dialect, tagParser *tags.Parser, defaultTimeZone *time.Location) *Statement
NewStatement creates a new statement
func (*Statement) BuildConds ¶
func (*Statement) BuildUpdates ¶
func (statement *Statement) BuildUpdates(tableValue reflect.Value, includeVersion, includeUpdated, includeNil, includeAutoIncr, update bool) ([]string, []interface{}, error)
BuildUpdates auto generating update columnes and values according a struct
func (*Statement) CondDeleted ¶
CondDeleted returns the conditions whether a record is soft deleted.
func (*Statement) ConvertIDSQL ¶
func (*Statement) ConvertSQLOrArgs ¶
func (*Statement) ConvertUpdateSQL ¶
func (*Statement) GenCondSQL ¶
func (*Statement) GenCountSQL ¶
GenCountSQL generates the SQL for counting
func (*Statement) GenCreateTableSQL ¶
func (*Statement) GenDelIndexSQL ¶
func (*Statement) GenExistSQL ¶
func (*Statement) GenFindSQL ¶
func (*Statement) GenIndexSQL ¶
func (*Statement) GenInsertMapSQL ¶
func (statement *Statement) GenInsertMapSQL(columns []string, args []interface{}) (string, []interface{}, error)
GenInsertMapSQL generates insert map SQL
func (*Statement) GenInsertSQL ¶
func (statement *Statement) GenInsertSQL(colNames []string, args []interface{}) (string, []interface{}, error)
GenInsertSQL generates insert beans SQL
func (*Statement) GenQuerySQL ¶
func (*Statement) GenUniqueSQL ¶
func (*Statement) GetUnscoped ¶
func (*Statement) ID ¶
ID generate "where id = ? " statement or for composite key "where key1 = ? and key2 = ?"
func (*Statement) Join ¶
func (statement *Statement) Join(joinOP string, tablename interface{}, condition string, args ...interface{}) *Statement
Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
func (*Statement) Nullable ¶
Nullable Update use only: update columns to null when value is nullable and zero-value
func (*Statement) OmitConditions ¶ added in v1.2.10
OmitConditions omit condition when generate SQL condition from beans
func (*Statement) ProcessIDParam ¶
ProcessIDParam handles the process of id condition
func (*Statement) ReplaceQuote ¶
func (*Statement) SetContextCache ¶
func (statement *Statement) SetContextCache(ctxCache contexts.ContextCache)
func (*Statement) SetNoAutoCondition ¶
NoAutoCondition if you do not want convert bean's field as query condition, then use this function
func (*Statement) SetRefBean ¶
func (*Statement) SetTable ¶
Table tempororily set table name, the parameter could be a string or a pointer of struct
func (*Statement) SetTableName ¶
func (*Statement) SetUnscoped ¶
Unscoped always disable struct tag "deleted"
func (*Statement) UseBool ¶
UseBool indicates that use bool fields as update contents and query contiditions
func (*Statement) Value2Interface ¶
func (statement *Statement) Value2Interface(col *schemas.Column, fieldValue reflect.Value) (interface{}, error)
Value2Interface convert a field value of a struct to interface for puting into database