Documentation
¶
Overview ¶
Package expr package 用于生成sql语句
Index ¶
- Variables
- func AllToAnd(exp Expr)
- func AllToOr(exp Expr)
- func AutoFuzzy(exp Expr)
- func WithCount(exp Expr)
- type AliasExpr
- type AroundExpr
- type BetweenExpr
- type BinaryExpr
- func Binary(left Expr, op string, right any) *BinaryExpr
- func Eq(left Expr, right any) *BinaryExpr
- func Ge(left Expr, right any) *BinaryExpr
- func Gt(left Expr, right any) *BinaryExpr
- func In(left Expr, name string, values ...any) *BinaryExpr
- func InValues(left Expr, values ...Expr) *BinaryExpr
- func Le(left Expr, right any) *BinaryExpr
- func Like(left Expr, right any) *BinaryExpr
- func Lt(left Expr, right any) *BinaryExpr
- func Ne(left Expr, right any) *BinaryExpr
- func NotIn(left Expr, name string, values ...any) *BinaryExpr
- func NotInValues(left Expr, values ...Expr) *BinaryExpr
- type ConstantExpr
- type DeleteExpr
- type DeleteExprFn
- type DeleteFilterFn
- type Expr
- type FilterFn
- func DeleteFilter(fn DeleteFilterFn) FilterFn
- func InsertFilter(fn InsertFilterFn) FilterFn
- func SelectFilter(fn SelectFilterFn) FilterFn
- func Set(exps ...Expr) FilterFn
- func UpdateFilter(fn UpdateFilterFn) FilterFn
- func UseCondition(exp Expr) FilterFn
- func UseLimit(limit int) FilterFn
- func UseLimits(limit int, offset int) FilterFn
- func UseOffset(offset int) FilterFn
- func UseOrderBy(exp Expr) FilterFn
- func UseSort(direct string, exprs ...Expr) FilterFn
- type Filters
- type FuncExpr
- type InsertExpr
- func (i *InsertExpr) Format(buf *TracedBuffer)
- func (i *InsertExpr) Into(table Expr) *InsertExpr
- func (i *InsertExpr) Set(colName string, value any) *InsertExpr
- func (i *InsertExpr) SetExpr(name Expr, value Expr) *InsertExpr
- func (i *InsertExpr) SetMap(data map[string]any) *InsertExpr
- func (i *InsertExpr) Values(values ...*BinaryExpr) *InsertExpr
- type InsertFilterFn
- type ListExpr
- type NameExpr
- func (n *NameExpr) Between(min, max any) *BetweenExpr
- func (n *NameExpr) Eq(value any) *BinaryExpr
- func (n *NameExpr) Format(buffer *TracedBuffer)
- func (n *NameExpr) Ge(value any) *BinaryExpr
- func (n *NameExpr) Gt(value any) *BinaryExpr
- func (n *NameExpr) In(values ...any) *BinaryExpr
- func (n *NameExpr) Le(value any) *BinaryExpr
- func (n *NameExpr) Like(value any) *BinaryExpr
- func (n *NameExpr) Lt(value any) *BinaryExpr
- func (n *NameExpr) Ne(value any) *BinaryExpr
- func (n *NameExpr) NotIn(values ...any) *BinaryExpr
- type RawExpr
- type SelectExpr
- func (s *SelectExpr) BuildCountExpr() *SelectExpr
- func (s *SelectExpr) Format(buffer *TracedBuffer)
- func (s *SelectExpr) From(from Expr) *SelectExpr
- func (s *SelectExpr) GroupBy(exp Expr) *SelectExpr
- func (s *SelectExpr) Having(exp Expr) *SelectExpr
- func (s *SelectExpr) Limit(limit int) *SelectExpr
- func (s *SelectExpr) Offset(offset int) *SelectExpr
- func (s *SelectExpr) OrderBy(exps ...Expr) *SelectExpr
- func (s *SelectExpr) Select(columns ...Expr) *SelectExpr
- func (s *SelectExpr) UseCount() bool
- func (s *SelectExpr) Where(exp Expr) *SelectExpr
- func (s *SelectExpr) WithCount() *SelectExpr
- func (s *SelectExpr) WithoutCount() *SelectExpr
- type SelectFilterFn
- type TracedBuffer
- func (t *TracedBuffer) Append(buf []byte) *TracedBuffer
- func (t *TracedBuffer) AppendArg(value any) *TracedBuffer
- func (t *TracedBuffer) AppendExprs(exprs ...Expr) *TracedBuffer
- func (t *TracedBuffer) AppendKeyword(keyword string) *TracedBuffer
- func (t *TracedBuffer) AppendKeywordWithSpace(keyword string) *TracedBuffer
- func (t *TracedBuffer) AppendNamedArg(name string, value any) *TracedBuffer
- func (t *TracedBuffer) AppendString(s string) *TracedBuffer
- func (t *TracedBuffer) Build(exp Expr) (string, []any, error)
- func (t *TracedBuffer) BuildNamed(exp Expr) (string, map[string]any, error)
- func (t *TracedBuffer) NewLine() *TracedBuffer
- type Tuple
- type UnaryExpr
- type UpdateExpr
- type UpdateFilterFn
- type ValueExpr
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type AliasExpr ¶
AliasExpr 别名表达式
func (*AliasExpr) Format ¶
func (a *AliasExpr) Format(buffer *TracedBuffer)
type AroundExpr ¶
func (*AroundExpr) Format ¶
func (s *AroundExpr) Format(buffer *TracedBuffer)
type BetweenExpr ¶
func (*BetweenExpr) Format ¶
func (b *BetweenExpr) Format(buffer *TracedBuffer)
type BinaryExpr ¶
BinaryExpr 二元表达式
func Eq ¶
func Eq(left Expr, right any) *BinaryExpr
func Ge ¶
func Ge(left Expr, right any) *BinaryExpr
func Gt ¶
func Gt(left Expr, right any) *BinaryExpr
func InValues ¶
func InValues(left Expr, values ...Expr) *BinaryExpr
func Le ¶
func Le(left Expr, right any) *BinaryExpr
func Like ¶
func Like(left Expr, right any) *BinaryExpr
func Lt ¶
func Lt(left Expr, right any) *BinaryExpr
func Ne ¶
func Ne(left Expr, right any) *BinaryExpr
func NotInValues ¶
func NotInValues(left Expr, values ...Expr) *BinaryExpr
func (*BinaryExpr) Format ¶
func (b *BinaryExpr) Format(buffer *TracedBuffer)
type ConstantExpr ¶
type ConstantExpr struct {
Value any
}
func Const ¶
func Const(value any) *ConstantExpr
Const 常量, 例如:Const(1), Const("a"),和Raw不同的是,Const会自动将值转换为SQL语句中的常量,例如:Const(1)会被格式化为:1,Const("a")会被格式化为:'a'
func (*ConstantExpr) Format ¶
func (c *ConstantExpr) Format(buffer *TracedBuffer)
type DeleteExpr ¶
func Delete ¶
func Delete(table Expr) *DeleteExpr
func (*DeleteExpr) Delete ¶
func (d *DeleteExpr) Delete(table Expr) *DeleteExpr
func (*DeleteExpr) Format ¶
func (d *DeleteExpr) Format(buf *TracedBuffer)
func (*DeleteExpr) Where ¶
func (d *DeleteExpr) Where(exp Expr) *DeleteExpr
type DeleteExprFn ¶
type DeleteExprFn func(*DeleteExpr)
func UseDeleteCondition ¶
func UseDeleteCondition(exp Expr) DeleteExprFn
type DeleteFilterFn ¶
type DeleteFilterFn func(s *DeleteExpr)
type FilterFn ¶
type FilterFn func(Expr)
func DeleteFilter ¶
func DeleteFilter(fn DeleteFilterFn) FilterFn
func InsertFilter ¶
func InsertFilter(fn InsertFilterFn) FilterFn
func SelectFilter ¶
func SelectFilter(fn SelectFilterFn) FilterFn
func UpdateFilter ¶
func UpdateFilter(fn UpdateFilterFn) FilterFn
func UseOrderBy ¶
type InsertExpr ¶
type InsertExpr struct { Table Expr ValueExprs []*BinaryExpr }
InsertExpr is a struct for insert expression
func InsertInto ¶
func InsertInto(table Expr, values ...*BinaryExpr) *InsertExpr
InsertInto 创建一个InsertExpr并设置表名
func (*InsertExpr) Format ¶
func (i *InsertExpr) Format(buf *TracedBuffer)
func (*InsertExpr) Into ¶
func (i *InsertExpr) Into(table Expr) *InsertExpr
Into is a function to set table
func (*InsertExpr) Set ¶
func (i *InsertExpr) Set(colName string, value any) *InsertExpr
func (*InsertExpr) SetExpr ¶
func (i *InsertExpr) SetExpr(name Expr, value Expr) *InsertExpr
func (*InsertExpr) SetMap ¶
func (i *InsertExpr) SetMap(data map[string]any) *InsertExpr
func (*InsertExpr) Values ¶
func (i *InsertExpr) Values(values ...*BinaryExpr) *InsertExpr
type InsertFilterFn ¶
type InsertFilterFn func(s *InsertExpr)
type ListExpr ¶
type ListExpr struct { Prefix Expr Separator string Placeholder string ExprList []Expr Suffix Expr }
func (*ListExpr) Format ¶
func (l *ListExpr) Format(buffer *TracedBuffer)
type NameExpr ¶
func Name ¶
Name 字段名、表名、别名等 例如:Name("id"):mysql 驱动下则会被格式化为: `id` 例如:如果有限定名称Name("id", "user"),则会被格式化为: `user`.`id`,如果有多个限定名称Name("id", "user", "t"),则会被格式化为: `user`.`t`.`id`
func (*NameExpr) Between ¶
func (n *NameExpr) Between(min, max any) *BetweenExpr
func (*NameExpr) Eq ¶
func (n *NameExpr) Eq(value any) *BinaryExpr
func (*NameExpr) Format ¶
func (n *NameExpr) Format(buffer *TracedBuffer)
func (*NameExpr) Ge ¶
func (n *NameExpr) Ge(value any) *BinaryExpr
func (*NameExpr) Gt ¶
func (n *NameExpr) Gt(value any) *BinaryExpr
func (*NameExpr) In ¶
func (n *NameExpr) In(values ...any) *BinaryExpr
func (*NameExpr) Le ¶
func (n *NameExpr) Le(value any) *BinaryExpr
func (*NameExpr) Like ¶
func (n *NameExpr) Like(value any) *BinaryExpr
func (*NameExpr) Lt ¶
func (n *NameExpr) Lt(value any) *BinaryExpr
func (*NameExpr) Ne ¶
func (n *NameExpr) Ne(value any) *BinaryExpr
func (*NameExpr) NotIn ¶
func (n *NameExpr) NotIn(values ...any) *BinaryExpr
type RawExpr ¶
type RawExpr struct {
Value any
}
func (*RawExpr) Format ¶
func (r *RawExpr) Format(buffer *TracedBuffer)
type SelectExpr ¶
type SelectExpr struct { Columns Expr FromExpr Expr WhereExpr Expr GroupByExpr Expr HavingExpr Expr OrderByExpr Expr // contains filtered or unexported fields }
func Select ¶
func Select(columns ...Expr) *SelectExpr
func (*SelectExpr) BuildCountExpr ¶
func (s *SelectExpr) BuildCountExpr() *SelectExpr
func (*SelectExpr) Format ¶
func (s *SelectExpr) Format(buffer *TracedBuffer)
func (*SelectExpr) From ¶
func (s *SelectExpr) From(from Expr) *SelectExpr
func (*SelectExpr) GroupBy ¶
func (s *SelectExpr) GroupBy(exp Expr) *SelectExpr
func (*SelectExpr) Having ¶
func (s *SelectExpr) Having(exp Expr) *SelectExpr
func (*SelectExpr) Limit ¶
func (s *SelectExpr) Limit(limit int) *SelectExpr
func (*SelectExpr) Offset ¶
func (s *SelectExpr) Offset(offset int) *SelectExpr
func (*SelectExpr) OrderBy ¶
func (s *SelectExpr) OrderBy(exps ...Expr) *SelectExpr
func (*SelectExpr) Select ¶
func (s *SelectExpr) Select(columns ...Expr) *SelectExpr
func (*SelectExpr) UseCount ¶
func (s *SelectExpr) UseCount() bool
func (*SelectExpr) Where ¶
func (s *SelectExpr) Where(exp Expr) *SelectExpr
func (*SelectExpr) WithCount ¶
func (s *SelectExpr) WithCount() *SelectExpr
func (*SelectExpr) WithoutCount ¶
func (s *SelectExpr) WithoutCount() *SelectExpr
type SelectFilterFn ¶
type SelectFilterFn func(s *SelectExpr)
type TracedBuffer ¶
type TracedBuffer struct { NamedVar bool *dialect.Driver strings.Builder // contains filtered or unexported fields }
TracedBuffer is a buffer that can be used to trace the
func NewTracedBuffer ¶
func NewTracedBuffer(driver *dialect.Driver) *TracedBuffer
func (*TracedBuffer) Append ¶
func (t *TracedBuffer) Append(buf []byte) *TracedBuffer
func (*TracedBuffer) AppendArg ¶
func (t *TracedBuffer) AppendArg(value any) *TracedBuffer
func (*TracedBuffer) AppendExprs ¶
func (t *TracedBuffer) AppendExprs(exprs ...Expr) *TracedBuffer
func (*TracedBuffer) AppendKeyword ¶
func (t *TracedBuffer) AppendKeyword(keyword string) *TracedBuffer
func (*TracedBuffer) AppendKeywordWithSpace ¶
func (t *TracedBuffer) AppendKeywordWithSpace(keyword string) *TracedBuffer
func (*TracedBuffer) AppendNamedArg ¶
func (t *TracedBuffer) AppendNamedArg(name string, value any) *TracedBuffer
func (*TracedBuffer) AppendString ¶
func (t *TracedBuffer) AppendString(s string) *TracedBuffer
func (*TracedBuffer) BuildNamed ¶
func (*TracedBuffer) NewLine ¶
func (t *TracedBuffer) NewLine() *TracedBuffer
type UnaryExpr ¶
UnaryExpr 一元表达式
func (*UnaryExpr) Format ¶
func (u *UnaryExpr) Format(buffer *TracedBuffer)
type UpdateExpr ¶
func Update ¶
func Update(table Expr) *UpdateExpr
func (*UpdateExpr) Format ¶
func (u *UpdateExpr) Format(buf *TracedBuffer)
func (*UpdateExpr) Set ¶
func (u *UpdateExpr) Set(values ...Expr) *UpdateExpr
func (*UpdateExpr) Update ¶
func (u *UpdateExpr) Update(table Expr) *UpdateExpr
func (*UpdateExpr) Where ¶
func (u *UpdateExpr) Where(exp Expr) *UpdateExpr
type UpdateFilterFn ¶
type UpdateFilterFn func(s *UpdateExpr)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.