sql_select

package
v4.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STRING_OPT_SKIP_WITH    = 1
	STRING_OPT_INLINE_WITH  = 2
	ORDER_BY_DIRECTION_ASC  = 3
	ORDER_BY_DIRECTION_DESC = 4
	WITH_REF_NO_ALIAS       = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Aliased

type Aliased interface {
	GetExpr() SQLObject
	GetAlias() string
	String(ctx *Ctx, options ...int) (string, error)
}

type BoolVal

type BoolVal struct {
	// contains filtered or unexported fields
}

func (*BoolVal) String

func (b *BoolVal) String(ctx *Ctx, options ...int) (string, error)

type CNot

type CNot struct {
	// contains filtered or unexported fields
}

func (*CNot) GetEntity

func (n *CNot) GetEntity() []SQLObject

func (*CNot) GetFunction

func (n *CNot) GetFunction() string

func (*CNot) String

func (n *CNot) String(ctx *Ctx, options ...int) (string, error)

type CNotNull

type CNotNull struct {
	// contains filtered or unexported fields
}

func (*CNotNull) GetEntity

func (c *CNotNull) GetEntity() []SQLObject

func (*CNotNull) GetFunction

func (c *CNotNull) GetFunction() string

func (*CNotNull) String

func (c *CNotNull) String(ctx *Ctx, options ...int) (string, error)

type Col

type Col struct {
	// contains filtered or unexported fields
}

func (*Col) GetAlias

func (c *Col) GetAlias() string

func (*Col) GetExpr

func (c *Col) GetExpr() SQLObject

func (*Col) String

func (c *Col) String(ctx *Ctx, options ...int) (string, error)

type Ctx

type Ctx struct {
	Params map[string]SQLObject
	Result map[string]SQLObject
	// contains filtered or unexported fields
}

func DefaultCtx

func DefaultCtx() *Ctx

func (*Ctx) Id

func (c *Ctx) Id() int

type CtxParam

type CtxParam struct {
	// contains filtered or unexported fields
}

func NewCtxParam

func NewCtxParam(name string, def *string) *CtxParam

func NewCtxParamOrDef

func NewCtxParamOrDef(name string, def string) *CtxParam

func (*CtxParam) String

func (c *CtxParam) String(ctx *Ctx, options ...int) (string, error)

type CustomCol

type CustomCol struct {
	// contains filtered or unexported fields
}

func (*CustomCol) String

func (c *CustomCol) String(ctx *Ctx, options ...int) (string, error)

type FloatVal

type FloatVal struct {
	// contains filtered or unexported fields
}

func (*FloatVal) String

func (f *FloatVal) String(ctx *Ctx, options ...int) (string, error)

type ISelect

type ISelect interface {
	Distinct(distinct bool) ISelect
	GetDistinct() bool
	Select(cols ...SQLObject) ISelect
	GetSelect() []SQLObject
	From(table SQLObject) ISelect
	GetFrom() SQLObject
	AndWhere(clauses ...SQLCondition) ISelect
	OrWhere(clauses ...SQLCondition) ISelect
	GetWhere() SQLCondition
	AndPreWhere(clauses ...SQLCondition) ISelect
	OrPreWhere(clauses ...SQLCondition) ISelect
	GetPreWhere() SQLCondition
	AndHaving(clauses ...SQLCondition) ISelect
	OrHaving(clauses ...SQLCondition) ISelect
	GetHaving() SQLCondition
	SetHaving(having SQLCondition) ISelect
	GroupBy(fields ...SQLObject) ISelect
	GetGroupBy() []SQLObject
	OrderBy(fields ...SQLObject) ISelect
	GetOrderBy() []SQLObject
	Limit(limit ...SQLObject) ISelect
	AddLimit(limit ...SQLObject) ISelect
	GetLimit() SQLObject
	Offset(offset SQLObject) ISelect
	GetOffset() SQLObject
	With(withs ...*With) ISelect
	AddWith(withs ...*With) ISelect
	DropWith(alias ...string) ISelect
	GetWith() []*With
	Join(joins ...*Join) ISelect
	AddJoin(joins ...*Join) ISelect
	GetJoin() []*Join
	String(ctx *Ctx, options ...int) (string, error)
	SetSetting(name string, value string) ISelect
	GetSettings(table SQLObject) map[string]string
	AddWindows(windows ...*WindowFunction) ISelect
	GetWindows() []*WindowFunction
	SetWindows(windows ...*WindowFunction) ISelect
}

func NewSelect

func NewSelect() ISelect

type In

type In struct {
	// contains filtered or unexported fields
}

func NewIn

func NewIn(left SQLObject, right ...SQLObject) *In

func (*In) GetEntity

func (in *In) GetEntity() []SQLObject

func (*In) GetFunction

func (in *In) GetFunction() string

func (*In) String

func (in *In) String(ctx *Ctx, options ...int) (string, error)

type IntVal

type IntVal struct {
	// contains filtered or unexported fields
}

func NewIntVal

func NewIntVal(val int64) *IntVal

func (*IntVal) String

func (i *IntVal) String(ctx *Ctx, options ...int) (string, error)

type Join

type Join struct {
	// contains filtered or unexported fields
}

func NewJoin

func NewJoin(tp string, table SQLObject, on SQLCondition) *Join

func (*Join) GetOn

func (l *Join) GetOn() SQLCondition

func (*Join) GetTable

func (l *Join) GetTable() SQLObject

func (*Join) String

func (l *Join) String(ctx *Ctx, options ...int) (string, error)

type LimitBy added in v4.1.1

type LimitBy struct {
	// contains filtered or unexported fields
}

func NewLimitBy added in v4.1.1

func NewLimitBy(limit SQLObject, exprs ...SQLObject) *LimitBy

func (*LimitBy) GetExprs added in v4.1.1

func (l *LimitBy) GetExprs() []SQLObject

func (*LimitBy) GetLimit added in v4.1.1

func (l *LimitBy) GetLimit() SQLObject

func (*LimitBy) String added in v4.1.1

func (l *LimitBy) String(ctx *Ctx, options ...int) (string, error)

type LogicalOp

type LogicalOp struct {
	// contains filtered or unexported fields
}

func And

func And(clauses ...SQLCondition) *LogicalOp

func BinaryLogicalOp

func BinaryLogicalOp(fn string, left SQLObject, right SQLObject) *LogicalOp

func Eq

func Eq(left SQLObject, right SQLObject) *LogicalOp

func Ge

func Ge(left SQLObject, right SQLObject) *LogicalOp

func Gt

func Gt(left SQLObject, right SQLObject) *LogicalOp

func Le

func Le(left SQLObject, right SQLObject) *LogicalOp

func Lt

func Lt(left SQLObject, right SQLObject) *LogicalOp

func Neq

func Neq(left SQLObject, right SQLObject) *LogicalOp

func NewGenericLogicalOp

func NewGenericLogicalOp(fn string, clauses ...SQLCondition) *LogicalOp

func Or

func Or(clauses ...SQLCondition) *LogicalOp

func (*LogicalOp) AppendEntity

func (op *LogicalOp) AppendEntity(clauses ...SQLCondition)

func (*LogicalOp) GetEntity

func (op *LogicalOp) GetEntity() []SQLObject

func (*LogicalOp) GetFunction

func (op *LogicalOp) GetFunction() string

func (*LogicalOp) String

func (op *LogicalOp) String(ctx *Ctx, options ...int) (string, error)

type OrderBy

type OrderBy struct {
	// contains filtered or unexported fields
}

func NewOrderBy

func NewOrderBy(col SQLObject, direction int) *OrderBy

func (*OrderBy) String

func (o *OrderBy) String(ctx *Ctx, options ...int) (string, error)

func (*OrderBy) WithFill

func (o *OrderBy) WithFill(from int64, to int64, step int64) *OrderBy

type RawObject

type RawObject struct {
	// contains filtered or unexported fields
}

func FmtRawObject

func FmtRawObject(tmpl string, arg ...interface{}) *RawObject

func NewRawObject

func NewRawObject(val string) *RawObject

func (*RawObject) String

func (r *RawObject) String(ctx *Ctx, options ...int) (string, error)

type SQLCondition

type SQLCondition interface {
	GetFunction() string
	GetEntity() []SQLObject
	String(ctx *Ctx, options ...int) (string, error)
}

func Not

func Not(expr SQLObject) SQLCondition

func NotNull

func NotNull(obj SQLObject) SQLCondition

type SQLObject

type SQLObject interface {
	String(ctx *Ctx, options ...int) (string, error)
}

func NewBoolVal

func NewBoolVal(b bool) SQLObject

func NewCol

func NewCol(expr SQLObject, alias string) SQLObject

func NewCustomCol

func NewCustomCol(fn func(ctx *Ctx, options ...int) (string, error)) SQLObject

func NewFloatVal

func NewFloatVal(f float64) SQLObject

func NewSimpleCol

func NewSimpleCol(name string, alias string) SQLObject

func NewStringVal

func NewStringVal(s string) SQLObject

type Select

type Select struct {
	// contains filtered or unexported fields
}

func (*Select) AddJoin

func (s *Select) AddJoin(joins ...*Join) ISelect

func (*Select) AddLimit added in v4.1.1

func (s *Select) AddLimit(limit ...SQLObject) ISelect

func (*Select) AddWindows

func (s *Select) AddWindows(windows ...*WindowFunction) ISelect

func (*Select) AddWith

func (s *Select) AddWith(withs ...*With) ISelect

func (*Select) AndHaving

func (s *Select) AndHaving(clauses ...SQLCondition) ISelect

func (*Select) AndPreWhere

func (s *Select) AndPreWhere(clauses ...SQLCondition) ISelect

func (*Select) AndWhere

func (s *Select) AndWhere(clauses ...SQLCondition) ISelect

func (*Select) Distinct

func (s *Select) Distinct(distinct bool) ISelect

func (*Select) DropWith

func (s *Select) DropWith(alias ...string) ISelect

func (*Select) From

func (s *Select) From(table SQLObject) ISelect

func (*Select) GetDistinct

func (s *Select) GetDistinct() bool

func (*Select) GetFrom

func (s *Select) GetFrom() SQLObject

func (*Select) GetGroupBy

func (s *Select) GetGroupBy() []SQLObject

func (*Select) GetHaving

func (s *Select) GetHaving() SQLCondition

func (*Select) GetJoin

func (s *Select) GetJoin() []*Join

func (*Select) GetLimit

func (s *Select) GetLimit() SQLObject

func (*Select) GetOffset

func (s *Select) GetOffset() SQLObject

func (*Select) GetOrderBy

func (s *Select) GetOrderBy() []SQLObject

func (*Select) GetPreWhere

func (s *Select) GetPreWhere() SQLCondition

func (*Select) GetSelect

func (s *Select) GetSelect() []SQLObject

func (*Select) GetSettings

func (s *Select) GetSettings(table SQLObject) map[string]string

func (*Select) GetWhere

func (s *Select) GetWhere() SQLCondition

func (*Select) GetWindows

func (s *Select) GetWindows() []*WindowFunction

func (*Select) GetWith

func (s *Select) GetWith() []*With

func (*Select) GroupBy

func (s *Select) GroupBy(fields ...SQLObject) ISelect

func (*Select) Join

func (s *Select) Join(joins ...*Join) ISelect

func (*Select) Limit

func (s *Select) Limit(limit ...SQLObject) ISelect

func (*Select) Offset

func (s *Select) Offset(offset SQLObject) ISelect

func (*Select) OrHaving

func (s *Select) OrHaving(clauses ...SQLCondition) ISelect

func (*Select) OrPreWhere

func (s *Select) OrPreWhere(clauses ...SQLCondition) ISelect

func (*Select) OrWhere

func (s *Select) OrWhere(clauses ...SQLCondition) ISelect

func (*Select) OrderBy

func (s *Select) OrderBy(fields ...SQLObject) ISelect

func (*Select) Select

func (s *Select) Select(cols ...SQLObject) ISelect

func (*Select) SetHaving

func (s *Select) SetHaving(having SQLCondition) ISelect

func (*Select) SetSetting

func (s *Select) SetSetting(name string, value string) ISelect

func (*Select) SetWindows

func (s *Select) SetWindows(windows ...*WindowFunction) ISelect

func (*Select) String

func (s *Select) String(ctx *Ctx, options ...int) (string, error)

func (*Select) With

func (s *Select) With(withs ...*With) ISelect

type StringVal

type StringVal struct {
	// contains filtered or unexported fields
}

func (*StringVal) String

func (s *StringVal) String(ctx *Ctx, options ...int) (string, error)

type WindowFunction

type WindowFunction struct {
	Alias       string
	PartitionBy []SQLObject
	OrderBy     []SQLObject
	Rows        bool
	Start       WindowPoint
	End         WindowPoint
}

func (*WindowFunction) String

func (w *WindowFunction) String(ctx *Ctx, options ...int) (string, error)

type WindowFunctionRef

type WindowFunctionRef struct {
	Fn *WindowFunction
}

func (*WindowFunctionRef) String

func (w *WindowFunctionRef) String(ctx *Ctx, options ...int) (string, error)

type WindowPoint

type WindowPoint struct {
	Unbounded   bool
	Offset      int32
	IsFollowing bool
}

func (*WindowPoint) String

func (w *WindowPoint) String(ctx *Ctx, options ...int) (string, error)

type With

type With struct {
	// contains filtered or unexported fields
}

func NewWith

func NewWith(query ISelect, alias string) *With

func (*With) GetAlias

func (w *With) GetAlias() string

func (*With) GetQuery

func (w *With) GetQuery() ISelect

func (*With) String

func (w *With) String(ctx *Ctx, options ...int) (string, error)

type WithRef

type WithRef struct {
	// contains filtered or unexported fields
}

func NewWithRef

func NewWithRef(ref *With) *WithRef

func (*WithRef) String

func (w *WithRef) String(ctx *Ctx, options ...int) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL