import "xorm.io/xorm/internal/statements"
cache.go column_map.go expr_param.go insert.go pk.go query.go statement.go statement_args.go update.go values.go
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") )
IsIDConditionWithNoTableErr return true if the err is ErrIDConditionWithNoTable
ErrIDConditionWithNoTable represents an error there is no reference table with an ID condition
func (err ErrIDConditionWithNoTable) Error() string
type ErrUnsupportedExprType struct {
// contains filtered or unexported fields
}
func (err ErrUnsupportedExprType) Error() string
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 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(dialect dialects.Dialect, tagParser *tags.Parser, defaultTimeZone *time.Location) *Statement
NewStatement creates a new statement
Alias set the table alias
AllCols update use only: update all columns
And add Where & and statement
Asc provide asc order by query condition, the input parameters are columns.
func (statement *Statement) BuildConds(table *schemas.Table, bean interface{}, includeVersion bool, includeUpdated bool, includeNil bool, includeAutoIncr bool, addedTableName bool) (builder.Cond, error)
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
Cols generate "col1, col2" statement
CondDeleted returns the conditions whether a record is soft deleted.
func (statement *Statement) ConvertSQLOrArgs(sqlOrArgs ...interface{}) (string, []interface{}, error)
Decr Generate "Update ... Set column = column - arg" statement
Desc generate `ORDER BY xx DESC`
Distinct generates "DISTINCT col1, col2 " statement
ForUpdate generates "SELECT ... FOR UPDATE" statement
GenCountSQL generates the SQL for counting
func (statement *Statement) GenInsertMapSQL(columns []string, args []interface{}) (string, []interface{}, error)
GenInsertMapSQL generates insert map SQL
func (statement *Statement) GenInsertSQL(colNames []string, args []interface{}) (string, []interface{}, error)
GenInsertSQL generates insert beans SQL
GenRawSQL generates correct raw sql
func (statement *Statement) GenSumSQL(bean interface{}, columns ...string) (string, []interface{}, error)
GroupBy generate "Group By keys" statement
Having generate "Having conditions" statement
ID generate "where id = ? " statement or for composite key "where key1 = ? and key2 = ?"
In generate "Where column IN (?) " statement
Incr Generate "Update ... Set column = column + arg" statement
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
Limit generate LIMIT start, limit statement
MustCols update use only: must update columns
NotIn generate "Where column NOT IN (?) " statement
Nullable Update use only: update columns to null when value is nullable and zero-value
Omit do not use the columns
Or add Where & Or statement
OrderBy generate "Order By order" statement
ProcessIDParam handles the process of id condition
Init reset all the statement's fields
SQL adds raw sql statement
Select replace select
func (statement *Statement) SetContextCache(ctxCache contexts.ContextCache)
SetExpr Generate "Update ... Set column = {expression}" statement
NoAutoCondition if you do not want convert bean's field as query condition, then use this function
Table tempororily set table name, the parameter could be a string or a pointer of struct
Unscoped always disable struct tag "deleted"
TableName return current tableName
Top generate LIMIT limit statement
UseBool indicates that use bool fields as update contents and query contiditions
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
Where add Where statement
func (statement *Statement) WriteArg(w *builder.BytesWriter, arg interface{}) error
func (statement *Statement) WriteArgs(w *builder.BytesWriter, args []interface{}) error
Package statements imports 15 packages (graph) and is imported by 2 packages. Updated 2021-01-19. Refresh now. Tools for package owners.