Documentation ¶
Index ¶
- Variables
- func IsIDConditionWithNoTableErr(err error) bool
- type ErrIDConditionWithNoTable
- type ErrInvalidIndexHintOperator
- type ErrUnsupportedExprType
- type Expr
- type QuoteReplacer
- 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) GenConditionsFromMap(m interface{}) ([]builder.Cond, error)
- func (statement *Statement) GenCountSQL(beans ...interface{}) (string, []interface{}, error)
- 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) GenInsertMultipleMapSQL(columns []string, argss [][]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) HasOrderBy() bool
- 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) IndexHint(op, forType, indexName string) error
- func (statement *Statement) Join(joinOP string, joinTable interface{}, condition interface{}, ...) *Statement
- func (statement *Statement) Limit(limit int, start ...int) *Statement
- func (statement *Statement) MergeConds(bean interface{}) error
- func (statement *Statement) MustCols(columns ...string) *Statement
- func (statement *Statement) NeedTableName() bool
- func (statement *Statement) NotIn(column string, args ...interface{}) *Statement
- func (statement *Statement) Nullable(columns ...string)
- func (statement *Statement) Omit(columns ...string)
- func (statement *Statement) Or(query interface{}, args ...interface{}) *Statement
- func (statement *Statement) OrderBy(order interface{}, args ...interface{}) *Statement
- func (statement *Statement) ProcessIDParam() error
- func (statement *Statement) QuoteReplacer(w *builder.BytesWriter) *QuoteReplacer
- func (statement *Statement) ReplaceQuote(sql string) string
- func (statement *Statement) Reset()
- func (statement *Statement) ResetOrderBy()
- 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
- func (statement *Statement) WriteDelete(realSQLWriter, deleteSQLWriter *builder.BytesWriter, ...) error
- func (statement *Statement) WriteInsertMultiple(w *builder.BytesWriter, tableName string, colNames []string, ...) error
- func (statement *Statement) WriteUpdate(updateWriter *builder.BytesWriter, cond builder.Cond, v reflect.Value, ...) 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") )
var ErrNoColumnName = errors.New("no column name")
var ErrNoColumnsTobeUpdated = errors.New("no columns found to be updated")
var ErrNotImplemented = errors.New("Not implemented")
ErrNotImplemented not implemented
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 ErrInvalidIndexHintOperator ¶
type ErrInvalidIndexHintOperator struct {
Op string
}
func (ErrInvalidIndexHintOperator) Error ¶
func (e ErrInvalidIndexHintOperator) Error() string
type ErrUnsupportedExprType ¶
type ErrUnsupportedExprType struct {
// contains filtered or unexported fields
}
ErrUnsupportedExprType represents an error with unsupported express type
func (ErrUnsupportedExprType) Error ¶
func (err ErrUnsupportedExprType) Error() string
type QuoteReplacer ¶
type QuoteReplacer struct { *builder.BytesWriter // contains filtered or unexported fields }
type Statement ¶
type Statement struct { RefTable *schemas.Table Start int LimitN *int 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 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 *Statement) BuildConds(table *schemas.Table, bean interface{}, includeVersion bool, includeUpdated bool, includeNil bool, includeAutoIncr bool, addedTableName bool) (builder.Cond, error)
BuildConds builds condition
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 ¶
ConvertIDSQL converts SQL with id
func (*Statement) ConvertSQLOrArgs ¶
func (statement *Statement) ConvertSQLOrArgs(sqlOrArgs ...interface{}) (string, []interface{}, error)
ConvertSQLOrArgs converts sql or args
func (*Statement) ConvertUpdateSQL ¶
ConvertUpdateSQL converts update SQL
func (*Statement) GenConditionsFromMap ¶
func (*Statement) GenCountSQL ¶
GenCountSQL generates the SQL for counting
func (*Statement) GenDelIndexSQL ¶
GenDelIndexSQL generate delete index SQL
func (*Statement) GenExistSQL ¶
GenExistSQL generates Exist SQL
func (*Statement) GenFindSQL ¶
GenFindSQL generates Find SQL
func (*Statement) GenIndexSQL ¶
GenIndexSQL generated create index SQL
func (*Statement) GenInsertMapSQL ¶
func (statement *Statement) GenInsertMapSQL(columns []string, args []interface{}) (string, []interface{}, error)
GenInsertMapSQL generates insert map SQL
func (*Statement) GenInsertMultipleMapSQL ¶
func (*Statement) GenInsertSQL ¶
func (statement *Statement) GenInsertSQL(colNames []string, args []interface{}) (string, []interface{}, error)
GenInsertSQL generates insert beans SQL
func (*Statement) GenQuerySQL ¶
GenQuerySQL generate query SQL
func (*Statement) GenSumSQL ¶
func (statement *Statement) GenSumSQL(bean interface{}, columns ...string) (string, []interface{}, error)
GenSumSQL generates sum SQL
func (*Statement) GenUniqueSQL ¶
GenUniqueSQL generates unique SQL
func (*Statement) GetUnscoped ¶
GetUnscoped return true if it's unscoped
func (*Statement) HasOrderBy ¶
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, joinTable interface{}, condition interface{}, args ...interface{}) *Statement
Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
func (*Statement) MergeConds ¶
MergeConds merge conditions from bean and id
func (*Statement) NeedTableName ¶
func (*Statement) Nullable ¶
Nullable Update use only: update columns to null when value is nullable and zero-value
func (*Statement) ProcessIDParam ¶
ProcessIDParam handles the process of id condition
func (*Statement) QuoteReplacer ¶
func (statement *Statement) QuoteReplacer(w *builder.BytesWriter) *QuoteReplacer
func (*Statement) ReplaceQuote ¶
ReplaceQuote replace sql key words with quote
func (*Statement) Reset ¶
func (statement *Statement) Reset()
Reset reset all the statement's fields
func (*Statement) ResetOrderBy ¶
func (statement *Statement) ResetOrderBy()
ResetOrderBy reset ordery conditions
func (*Statement) SetContextCache ¶
func (statement *Statement) SetContextCache(ctxCache contexts.ContextCache)
SetContextCache sets context cache
func (*Statement) SetNoAutoCondition ¶
SetNoAutoCondition if you do not want convert bean's field as query condition, then use this function
func (*Statement) SetRefBean ¶
SetRefBean set ref bean
func (*Statement) SetRefValue ¶
SetRefValue set ref value
func (*Statement) SetTable ¶
SetTable tempororily set table name, the parameter could be a string or a pointer of struct
func (*Statement) SetTableName ¶
SetTableName set table name
func (*Statement) SetUnscoped ¶
SetUnscoped 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 putting into database
func (*Statement) WriteArg ¶
func (statement *Statement) WriteArg(w *builder.BytesWriter, arg interface{}) error
WriteArg writes an arg
func (*Statement) WriteArgs ¶
func (statement *Statement) WriteArgs(w *builder.BytesWriter, args []interface{}) error
WriteArgs writes args