xorm: xorm.io/xorm/internal/statements Index | Files

package statements

import "xorm.io/xorm/internal/statements"


Package Files

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")

func IsIDConditionWithNoTableErr Uses

func IsIDConditionWithNoTableErr(err error) bool

IsIDConditionWithNoTableErr return true if the err is ErrIDConditionWithNoTable

type ErrIDConditionWithNoTable Uses

type ErrIDConditionWithNoTable struct {
    ID schemas.PK

ErrIDConditionWithNoTable represents an error there is no reference table with an ID condition

func (ErrIDConditionWithNoTable) Error Uses

func (err ErrIDConditionWithNoTable) Error() string

type ErrUnsupportedExprType Uses

type ErrUnsupportedExprType struct {
    // contains filtered or unexported fields

func (ErrUnsupportedExprType) Error Uses

func (err ErrUnsupportedExprType) Error() string

type Statement Uses

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 Uses

func NewStatement(dialect dialects.Dialect, tagParser *tags.Parser, defaultTimeZone *time.Location) *Statement

NewStatement creates a new statement

func (*Statement) Alias Uses

func (statement *Statement) Alias(alias string) *Statement

Alias set the table alias

func (*Statement) AllCols Uses

func (statement *Statement) AllCols() *Statement

AllCols update use only: update all columns

func (*Statement) And Uses

func (statement *Statement) And(query interface{}, args ...interface{}) *Statement

And add Where & and statement

func (*Statement) Asc Uses

func (statement *Statement) Asc(colNames ...string) *Statement

Asc provide asc order by query condition, the input parameters are columns.

func (*Statement) BuildConds Uses

func (statement *Statement) BuildConds(table *schemas.Table, bean interface{}, includeVersion bool, includeUpdated bool, includeNil bool, includeAutoIncr bool, addedTableName bool) (builder.Cond, error)

func (*Statement) BuildUpdates Uses

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) Cols Uses

func (statement *Statement) Cols(columns ...string) *Statement

Cols generate "col1, col2" statement

func (*Statement) ColumnStr Uses

func (statement *Statement) ColumnStr() string

func (*Statement) CondDeleted Uses

func (statement *Statement) CondDeleted(col *schemas.Column) builder.Cond

CondDeleted returns the conditions whether a record is soft deleted.

func (*Statement) Conds Uses

func (statement *Statement) Conds() builder.Cond

func (*Statement) ConvertIDSQL Uses

func (statement *Statement) ConvertIDSQL(sqlStr string) string

func (*Statement) ConvertSQLOrArgs Uses

func (statement *Statement) ConvertSQLOrArgs(sqlOrArgs ...interface{}) (string, []interface{}, error)

func (*Statement) ConvertUpdateSQL Uses

func (statement *Statement) ConvertUpdateSQL(sqlStr string) (string, string)

func (*Statement) Decr Uses

func (statement *Statement) Decr(column string, arg ...interface{}) *Statement

Decr Generate "Update ... Set column = column - arg" statement

func (*Statement) Desc Uses

func (statement *Statement) Desc(colNames ...string) *Statement

Desc generate `ORDER BY xx DESC`

func (*Statement) Distinct Uses

func (statement *Statement) Distinct(columns ...string) *Statement

Distinct generates "DISTINCT col1, col2 " statement

func (*Statement) ForUpdate Uses

func (statement *Statement) ForUpdate() *Statement

ForUpdate generates "SELECT ... FOR UPDATE" statement

func (*Statement) GenCondSQL Uses

func (statement *Statement) GenCondSQL(condOrBuilder interface{}) (string, []interface{}, error)

func (*Statement) GenConds Uses

func (statement *Statement) GenConds(bean interface{}) (string, []interface{}, error)

func (*Statement) GenCountSQL Uses

func (statement *Statement) GenCountSQL(beans ...interface{}) (string, []interface{}, error)

GenCountSQL generates the SQL for counting

func (*Statement) GenCreateTableSQL Uses

func (statement *Statement) GenCreateTableSQL() []string

func (*Statement) GenDelIndexSQL Uses

func (statement *Statement) GenDelIndexSQL() []string

func (*Statement) GenExistSQL Uses

func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interface{}, error)

func (*Statement) GenFindSQL Uses

func (statement *Statement) GenFindSQL(autoCond builder.Cond) (string, []interface{}, error)

func (*Statement) GenGetSQL Uses

func (statement *Statement) GenGetSQL(bean interface{}) (string, []interface{}, error)

func (*Statement) GenIndexSQL Uses

func (statement *Statement) GenIndexSQL() []string

func (*Statement) GenInsertMapSQL Uses

func (statement *Statement) GenInsertMapSQL(columns []string, args []interface{}) (string, []interface{}, error)

GenInsertMapSQL generates insert map SQL

func (*Statement) GenInsertSQL Uses

func (statement *Statement) GenInsertSQL(colNames []string, args []interface{}) (string, []interface{}, error)

GenInsertSQL generates insert beans SQL

func (*Statement) GenQuerySQL Uses

func (statement *Statement) GenQuerySQL(sqlOrArgs ...interface{}) (string, []interface{}, error)

func (*Statement) GenRawSQL Uses

func (statement *Statement) GenRawSQL() string

GenRawSQL generates correct raw sql

func (*Statement) GenSumSQL Uses

func (statement *Statement) GenSumSQL(bean interface{}, columns ...string) (string, []interface{}, error)

func (*Statement) GenUniqueSQL Uses

func (statement *Statement) GenUniqueSQL() []string

func (*Statement) GetUnscoped Uses

func (statement *Statement) GetUnscoped() bool

func (*Statement) GroupBy Uses

func (statement *Statement) GroupBy(keys string) *Statement

GroupBy generate "Group By keys" statement

func (*Statement) Having Uses

func (statement *Statement) Having(conditions string) *Statement

Having generate "Having conditions" statement

func (*Statement) ID Uses

func (statement *Statement) ID(id interface{}) *Statement

ID generate "where id = ? " statement or for composite key "where key1 = ? and key2 = ?"

func (*Statement) In Uses

func (statement *Statement) In(column string, args ...interface{}) *Statement

In generate "Where column IN (?) " statement

func (*Statement) Incr Uses

func (statement *Statement) Incr(column string, arg ...interface{}) *Statement

Incr Generate "Update ... Set column = column + arg" statement

func (*Statement) Join Uses

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) Limit Uses

func (statement *Statement) Limit(limit int, start ...int) *Statement

Limit generate LIMIT start, limit statement

func (*Statement) MustCols Uses

func (statement *Statement) MustCols(columns ...string) *Statement

MustCols update use only: must update columns

func (*Statement) NotIn Uses

func (statement *Statement) NotIn(column string, args ...interface{}) *Statement

NotIn generate "Where column NOT IN (?) " statement

func (*Statement) Nullable Uses

func (statement *Statement) Nullable(columns ...string)

Nullable Update use only: update columns to null when value is nullable and zero-value

func (*Statement) Omit Uses

func (statement *Statement) Omit(columns ...string)

Omit do not use the columns

func (*Statement) Or Uses

func (statement *Statement) Or(query interface{}, args ...interface{}) *Statement

Or add Where & Or statement

func (*Statement) OrderBy Uses

func (statement *Statement) OrderBy(order string) *Statement

OrderBy generate "Order By order" statement

func (*Statement) ProcessIDParam Uses

func (statement *Statement) ProcessIDParam() error

ProcessIDParam handles the process of id condition

func (*Statement) ReplaceQuote Uses

func (statement *Statement) ReplaceQuote(sql string) string

func (*Statement) Reset Uses

func (statement *Statement) Reset()

Init reset all the statement's fields

func (*Statement) SQL Uses

func (statement *Statement) SQL(query interface{}, args ...interface{}) *Statement

SQL adds raw sql statement

func (*Statement) Select Uses

func (statement *Statement) Select(str string) *Statement

Select replace select

func (*Statement) SetContextCache Uses

func (statement *Statement) SetContextCache(ctxCache contexts.ContextCache)

func (*Statement) SetExpr Uses

func (statement *Statement) SetExpr(column string, expression interface{}) *Statement

SetExpr Generate "Update ... Set column = {expression}" statement

func (*Statement) SetNoAutoCondition Uses

func (statement *Statement) SetNoAutoCondition(no ...bool) *Statement

NoAutoCondition if you do not want convert bean's field as query condition, then use this function

func (*Statement) SetRefBean Uses

func (statement *Statement) SetRefBean(bean interface{}) error

func (*Statement) SetRefValue Uses

func (statement *Statement) SetRefValue(v reflect.Value) error

func (*Statement) SetTable Uses

func (statement *Statement) SetTable(tableNameOrBean interface{}) error

Table tempororily set table name, the parameter could be a string or a pointer of struct

func (*Statement) SetTableName Uses

func (statement *Statement) SetTableName(tableName string)

func (*Statement) SetUnscoped Uses

func (statement *Statement) SetUnscoped() *Statement

Unscoped always disable struct tag "deleted"

func (*Statement) TableName Uses

func (statement *Statement) TableName() string

TableName return current tableName

func (*Statement) Top Uses

func (statement *Statement) Top(limit int) *Statement

Top generate LIMIT limit statement

func (*Statement) UseBool Uses

func (statement *Statement) UseBool(columns ...string) *Statement

UseBool indicates that use bool fields as update contents and query contiditions

func (*Statement) Value2Interface Uses

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

func (*Statement) Where Uses

func (statement *Statement) Where(query interface{}, args ...interface{}) *Statement

Where add Where statement

func (*Statement) WriteArg Uses

func (statement *Statement) WriteArg(w *builder.BytesWriter, arg interface{}) error

func (*Statement) WriteArgs Uses

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.