Documentation ¶
Index ¶
- Constants
- type Array
- func NewArray() Array
- func NewArrayBool(values []bool) Array
- func NewArrayFloat32(values []float32) Array
- func NewArrayFloat64(values []float64) Array
- func NewArrayInt(values []int) Array
- func NewArrayInt16(values []int16) Array
- func NewArrayInt32(values []int32) Array
- func NewArrayInt64(values []int64) Array
- func NewArrayInt8(values []int8) Array
- func NewArrayString(values []string) Array
- func NewArrayUint(values []uint) Array
- func NewArrayUint16(values []uint16) Array
- func NewArrayUint32(values []uint32) Array
- func NewArrayUint64(values []uint64) Array
- func NewArrayUint8(values []uint8) Array
- type Between
- type BoolEncoder
- type Column
- type ComparisonOperator
- type ConflictAction
- type ConflictNoAction
- type ConflictTarget
- type ConflictUpdateAction
- type Delete
- type Expression
- type From
- type GroupBy
- type Having
- type Identifier
- func (identifier Identifier) Between(from, to interface{}) Between
- func (identifier Identifier) Equal(value interface{}) InfixExpression
- func (identifier Identifier) GreaterThan(value interface{}) InfixExpression
- func (identifier Identifier) GreaterThanOrEqual(value interface{}) InfixExpression
- func (identifier Identifier) ILike(value interface{}) InfixExpression
- func (identifier Identifier) In(value ...interface{}) In
- func (identifier Identifier) Is(value interface{}) InfixExpression
- func (identifier Identifier) IsEmpty() bool
- func (identifier Identifier) IsNot(value interface{}) InfixExpression
- func (identifier Identifier) IsNull(value bool) InfixExpression
- func (identifier Identifier) LessThan(value interface{}) InfixExpression
- func (identifier Identifier) LessThanOrEqual(value interface{}) InfixExpression
- func (identifier Identifier) Like(value interface{}) InfixExpression
- func (identifier Identifier) NotBetween(from, to interface{}) Between
- func (identifier Identifier) NotEqual(value interface{}) InfixExpression
- func (identifier Identifier) NotILike(value interface{}) InfixExpression
- func (identifier Identifier) NotIn(value ...interface{}) In
- func (identifier Identifier) NotLike(value interface{}) InfixExpression
- func (identifier Identifier) Write(ctx *types.Context)
- type In
- type InfixExpression
- type Insert
- type Int64Encoder
- type Into
- type Join
- type Limit
- type LogicalOperator
- type Offset
- type On
- type OnConflict
- type Operator
- type Order
- type OrderBy
- type PairContainer
- func (pairs *PairContainer) Add(column Column, expression Expression)
- func (pairs PairContainer) IsEmpty() bool
- func (pairs *PairContainer) Set(column Column)
- func (pairs *PairContainer) Use(expression Expression)
- func (pairs PairContainer) Values() ([]Column, []Expression)
- func (pairs PairContainer) Write(ctx *types.Context)
- func (pairs PairContainer) WriteArray(ctx *types.Context)
- func (pairs PairContainer) WriteAssociative(ctx *types.Context)
- type PairMode
- type Prefix
- type Raw
- type Returning
- type Select
- type Set
- type Statement
- type StatementEncoder
- type StringEncoder
- type Suffix
- type Table
- type TimeEncoder
- type Update
- type Using
- type Value
- type Values
- type Where
Constants ¶
const ( // PairUnknownMode define an unknown mode. PairUnknownMode = PairMode(iota) // PairAssociativeMode define a key-value mode for PairContainer. PairAssociativeMode // PairArrayMode define a column-list mode for PairContainer. PairArrayMode )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
Values []Expression
}
Array contains a list of expression values.
func NewArrayBool ¶
NewArrayBool returns an expression array for "bool" type.
func NewArrayFloat32 ¶
NewArrayFloat32 returns an expression array for "float32" type.
func NewArrayFloat64 ¶
NewArrayFloat64 returns an expression array for "float64" type.
func NewArrayInt ¶
NewArrayInt returns an expression array for "int" type.
func NewArrayInt16 ¶
NewArrayInt16 returns an expression array for "int16" type.
func NewArrayInt32 ¶
NewArrayInt32 returns an expression array for "int32" type.
func NewArrayInt64 ¶
NewArrayInt64 returns an expression array for "int64" type.
func NewArrayInt8 ¶
NewArrayInt8 returns an expression array for "int8" type.
func NewArrayString ¶
NewArrayString returns an expression array for "string" type.
func NewArrayUint ¶
NewArrayUint returns an expression array for "uint" type.
func NewArrayUint16 ¶
NewArrayUint16 returns an expression array for "uint16" type.
func NewArrayUint32 ¶
NewArrayUint32 returns an expression array for "uint32" type.
func NewArrayUint64 ¶
NewArrayUint64 returns an expression array for "uint64" type.
func NewArrayUint8 ¶
NewArrayUint8 returns an expression array for "uint8" type.
func (*Array) AddValues ¶
func (array *Array) AddValues(values []Expression)
AddValues appends a collection of expression to given array.
type Between ¶
type Between struct { Identifier Identifier Operator ComparisonOperator From Expression And LogicalOperator To Expression }
Between is a BETWEEN expression.
func NewBetween ¶
func NewBetween(identifier Identifier, from, to Expression) Between
NewBetween returns a new Between instance using an inclusive operator.
func NewNotBetween ¶
func NewNotBetween(identifier Identifier, from, to Expression) Between
NewNotBetween returns a new Between instance using an exclusive operator.
type BoolEncoder ¶
type BoolEncoder interface {
Bool() bool
}
BoolEncoder can encode a value as a bool to creates a Value instance.
type Column ¶
Column is a column identifier.
func NewColumnAlias ¶
NewColumnAlias returns a new Column instance with an alias.
type ComparisonOperator ¶
type ComparisonOperator struct {
Operator types.ComparisonOperator
}
ComparisonOperator are used to evaluate two expressions using a comparison operator.
func NewComparisonOperator ¶
func NewComparisonOperator(operator types.ComparisonOperator) ComparisonOperator
NewComparisonOperator returns a new ComparisonOperator instance.
func (ComparisonOperator) IsEmpty ¶
func (operator ComparisonOperator) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (ComparisonOperator) Write ¶
func (operator ComparisonOperator) Write(ctx *types.Context)
Write exposes statement as a SQL query.
type ConflictAction ¶
type ConflictAction interface { Statement // contains filtered or unexported methods }
ConflictAction is a action used by ON CONFLICT expression. It can be either DO NOTHING, or a DO UPDATE clause.
type ConflictNoAction ¶
type ConflictNoAction struct{}
ConflictNoAction is a DO NOTHING clause on ON CONFLICT expression.
func NewConflictNoAction ¶
func NewConflictNoAction() ConflictNoAction
NewConflictNoAction returns a new ConflictNoAction instance.
func (ConflictNoAction) IsEmpty ¶
func (ConflictNoAction) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (ConflictNoAction) Write ¶
func (ConflictNoAction) Write(ctx *types.Context)
Write exposes statement as a SQL query.
type ConflictTarget ¶
type ConflictTarget struct {
Columns []Column
}
ConflictTarget is a column identifier.
func NewConflictTarget ¶
func NewConflictTarget(columns []Column) ConflictTarget
NewConflictTarget returns a new ConflictTarget instance.
func (ConflictTarget) IsEmpty ¶
func (target ConflictTarget) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (ConflictTarget) Write ¶
func (target ConflictTarget) Write(ctx *types.Context)
Write exposes statement as a SQL query.
type ConflictUpdateAction ¶
type ConflictUpdateAction struct {
Set Set
}
ConflictUpdateAction is a DO UPDATE clause on ON CONFLICT expression.
func NewConflictUpdateAction ¶
func NewConflictUpdateAction(set Set) ConflictUpdateAction
NewConflictUpdateAction returns a new ConflictUpdateAction instance.
func (ConflictUpdateAction) IsEmpty ¶
func (action ConflictUpdateAction) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (ConflictUpdateAction) Write ¶
func (action ConflictUpdateAction) Write(ctx *types.Context)
Write exposes statement as a SQL query.
type Delete ¶
Delete is a DELETE statement.
type Expression ¶
type Expression interface { Statement // contains filtered or unexported methods }
Expression is a SQL expression.
func NewArrayExpression ¶
func NewArrayExpression(values ...interface{}) Expression
NewArrayExpression creates a new Expression using a list of values.
func NewExpression ¶
func NewExpression(arg interface{}) Expression
NewExpression returns a new Expression instance from arg.
type From ¶
From is a FROM clause.
type GroupBy ¶
type GroupBy struct {
Columns []Column
}
GroupBy is a GROUP BY clause.
func NewGroupBy ¶
NewGroupBy returns a new GroupBy instance.
type Having ¶
type Having struct { Statement Condition Expression }
Having is a HAVING clause.
func NewHaving ¶
func NewHaving(expression Expression) Having
NewHaving returns a new Having instance.
func (Having) And ¶
func (having Having) And(right Expression) Having
And appends given Expression using AND as logical operator.
func (Having) Or ¶
func (having Having) Or(right Expression) Having
Or appends given Expression using OR as logical operator.
type Identifier ¶
type Identifier struct {
Identifier string
}
Identifier is an identifier.
func NewIdentifier ¶
func NewIdentifier(identifier string) Identifier
NewIdentifier returns a new Identifier.
func (Identifier) Between ¶
func (identifier Identifier) Between(from, to interface{}) Between
Between performs a "between" condition.
func (Identifier) Equal ¶
func (identifier Identifier) Equal(value interface{}) InfixExpression
Equal performs an "equal" comparison.
func (Identifier) GreaterThan ¶
func (identifier Identifier) GreaterThan(value interface{}) InfixExpression
GreaterThan performs a "greater than" comparison.
func (Identifier) GreaterThanOrEqual ¶
func (identifier Identifier) GreaterThanOrEqual(value interface{}) InfixExpression
GreaterThanOrEqual performs a "greater than or equal to" comparison.
func (Identifier) ILike ¶
func (identifier Identifier) ILike(value interface{}) InfixExpression
ILike performs a "ilike" condition.
func (Identifier) In ¶
func (identifier Identifier) In(value ...interface{}) In
In performs a "in" condition.
func (Identifier) Is ¶
func (identifier Identifier) Is(value interface{}) InfixExpression
Is performs a "is" comparison.
func (Identifier) IsEmpty ¶
func (identifier Identifier) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (Identifier) IsNot ¶
func (identifier Identifier) IsNot(value interface{}) InfixExpression
IsNot performs a "is not" comparison.
func (Identifier) IsNull ¶
func (identifier Identifier) IsNull(value bool) InfixExpression
IsNull performs a "is null" comparison.
func (Identifier) LessThan ¶
func (identifier Identifier) LessThan(value interface{}) InfixExpression
LessThan performs a "less than" comparison.
func (Identifier) LessThanOrEqual ¶
func (identifier Identifier) LessThanOrEqual(value interface{}) InfixExpression
LessThanOrEqual performs a "less than or equal to" comparison.
func (Identifier) Like ¶
func (identifier Identifier) Like(value interface{}) InfixExpression
Like performs a "like" condition.
func (Identifier) NotBetween ¶
func (identifier Identifier) NotBetween(from, to interface{}) Between
NotBetween performs a "not between" condition.
func (Identifier) NotEqual ¶
func (identifier Identifier) NotEqual(value interface{}) InfixExpression
NotEqual performs a "not equal" comparison.
func (Identifier) NotILike ¶
func (identifier Identifier) NotILike(value interface{}) InfixExpression
NotILike performs a "not ilike" condition.
func (Identifier) NotIn ¶
func (identifier Identifier) NotIn(value ...interface{}) In
NotIn performs a "not in" condition.
func (Identifier) NotLike ¶
func (identifier Identifier) NotLike(value interface{}) InfixExpression
NotLike performs a "not like" condition.
func (Identifier) Write ¶
func (identifier Identifier) Write(ctx *types.Context)
Write exposes statement as a SQL query.
type In ¶
type In struct { Identifier Identifier Operator ComparisonOperator Value Expression }
In is a IN expression.
func NewIn ¶
func NewIn(identifier Identifier, value Expression) In
NewIn returns a new In instance using an inclusive operator.
func NewNotIn ¶
func NewNotIn(identifier Identifier, value Expression) In
NewNotIn returns a new In instance using an exclusive operator.
func (In) And ¶
func (in In) And(value Expression) InfixExpression
And creates a new InfixExpression using given Expression.
func (In) Or ¶
func (in In) Or(value Expression) InfixExpression
Or creates a new InfixExpression using given Expression.
type InfixExpression ¶
type InfixExpression struct { Left Expression Operator Operator Right Expression }
InfixExpression is an Expression that has a left and right operand with an operator. For example, the expression 'id >= 30' is an infix expression.
func NewInfixExpression ¶
func NewInfixExpression(left Expression, operator Operator, right Expression) InfixExpression
NewInfixExpression returns a new InfixExpression instance.
func (InfixExpression) And ¶
func (expression InfixExpression) And(value Expression) InfixExpression
And creates a new InfixExpression using given Expression.
func (InfixExpression) IsEmpty ¶
func (expression InfixExpression) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (InfixExpression) Or ¶
func (expression InfixExpression) Or(value Expression) InfixExpression
Or creates a new InfixExpression using given Expression.
func (InfixExpression) Write ¶
func (expression InfixExpression) Write(ctx *types.Context)
Write exposes statement as a SQL query.
type Insert ¶
type Insert struct { Into Into Columns []Column Values Values OnConflict OnConflict Returning Returning }
Insert is a INSERT statement.
type Int64Encoder ¶
type Int64Encoder interface {
Int64() int64
}
Int64Encoder can encode a value as a int64 to creates a Value instance.
type Into ¶
type Into struct {
Table Table
}
Into is a INTO clause.
type Join ¶
Join is a JOIN clause.
func NewInnerJoin ¶
NewInnerJoin returns a new Join instance using an INNER JOIN.
func NewLeftJoin ¶
NewLeftJoin returns a new Join instance using a LEFT JOIN.
func NewRightJoin ¶
NewRightJoin returns a new Join instance using a RIGHT JOIN.
type Limit ¶
type Limit struct {
Count int64
}
Limit is a LIMIT clause.
type LogicalOperator ¶
type LogicalOperator struct {
Operator types.LogicalOperator
}
LogicalOperator are used to evaluate two expressions using a logical operator.
func NewAndOperator ¶
func NewAndOperator() LogicalOperator
NewAndOperator returns a new AND LogicalOperator instance.
func NewLogicalOperator ¶
func NewLogicalOperator(operator types.LogicalOperator) LogicalOperator
NewLogicalOperator returns a new LogicalOperator instance.
func NewOrOperator ¶
func NewOrOperator() LogicalOperator
NewOrOperator returns a new OR LogicalOperator instance.
func (LogicalOperator) IsEmpty ¶
func (operator LogicalOperator) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (LogicalOperator) Write ¶
func (operator LogicalOperator) Write(ctx *types.Context)
Write exposes statement as a SQL query.
type Offset ¶
type Offset struct {
Start int64
}
Offset is a OFFSET clause.
type OnConflict ¶
type OnConflict struct { Target ConflictTarget Action ConflictAction }
OnConflict is a ON CONFLICT expression.
func NewOnConflict ¶
func NewOnConflict(target ConflictTarget, action ConflictAction) OnConflict
NewOnConflict returns a new OnConflict instance.
func (OnConflict) IsEmpty ¶
func (conflict OnConflict) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (OnConflict) Write ¶
func (conflict OnConflict) Write(ctx *types.Context)
Write exposes statement as a SQL query.
type Operator ¶
type Operator interface { Statement // contains filtered or unexported methods }
Operator are used to compose expressions.
type Order ¶
Order is an expression of a ORDER BY clause.
type OrderBy ¶
type OrderBy struct {
Orders []Order
}
OrderBy is a ORDER BY clause.
func NewOrderBy ¶
NewOrderBy returns a new OrderBy instance.
type PairContainer ¶
type PairContainer struct { Mode PairMode Map map[Column]Expression Columns []Column Expressions []Expression }
PairContainer is a composite collection that store a list of values for SET clause.
func NewPairContainer ¶
func NewPairContainer() PairContainer
NewPairContainer creates a new PairContainer.
func (*PairContainer) Add ¶
func (pairs *PairContainer) Add(column Column, expression Expression)
Add appends given column and expression. It will configure Set's syntax to key-value (a.k.a "standard", "default" or "associative").
Example:
- SET foo = 1, bar = 2, baz = 3
func (PairContainer) IsEmpty ¶
func (pairs PairContainer) IsEmpty() bool
IsEmpty returns true if statement is undefined.
func (*PairContainer) Set ¶
func (pairs *PairContainer) Set(column Column)
Set appends given column. It will configure Set's syntax to column-list. You may use Use(...) function to provide required expressions.
Example:
- SET (foo, bar, baz) = (1, 2, 3)
- SET (foo, bar, baz) = (sub-select)
func (*PairContainer) Use ¶
func (pairs *PairContainer) Use(expression Expression)
Use appends given expression if Set's syntax is defined column-list. You have to use Set(...) function to provide required columns.
Example:
- SET (foo, bar, baz) = (1, 2, 3)
- SET (foo, bar, baz) = (sub-select)
func (PairContainer) Values ¶
func (pairs PairContainer) Values() ([]Column, []Expression)
Values returns columns and expressions of current instance.
func (PairContainer) Write ¶
func (pairs PairContainer) Write(ctx *types.Context)
Write exposes statement as a SQL query.
func (PairContainer) WriteArray ¶
func (pairs PairContainer) WriteArray(ctx *types.Context)
WriteArray exposes statement as a SQL query using a column-list syntax.
func (PairContainer) WriteAssociative ¶
func (pairs PairContainer) WriteAssociative(ctx *types.Context)
WriteAssociative exposes statement as a SQL query using a key-value syntax.
type Prefix ¶
type Prefix struct {
Prefix string
}
Prefix is a prefix expression.
type Returning ¶
type Returning struct {
Columns []Column
}
Returning is a RETURNING clause.
func NewReturning ¶
NewReturning returns a new Returning instance.
type Select ¶
type Select struct { Prefix Prefix Distinct bool Columns []Column From From Joins []Join Where Where GroupBy GroupBy Having Having OrderBy OrderBy Limit Limit Offset Offset Suffix Suffix }
Select is a SELECT statement.
type Statement ¶
type Statement interface { // IsEmpty returns true if statement is undefined. IsEmpty() bool // Write exposes statement as a SQL query. Write(ctx *types.Context) }
Statement is the interface of the component which is the minimum unit constituting SQL. All types that implement this interface can be built as SQL.
type StatementEncoder ¶
type StatementEncoder interface {
Statement() Statement
}
StatementEncoder can encode a value as a statement to creates a Expression instance.
type StringEncoder ¶
type StringEncoder interface {
String() string
}
StringEncoder can encode a value as a string to creates a Value instance.
type Suffix ¶
type Suffix struct {
Suffix string
}
Suffix is a suffix expression.
type Table ¶
Table is a table identifier.
func NewTableAlias ¶
NewTableAlias returns a new Table instance with an alias.
type TimeEncoder ¶
TimeEncoder can encode a value as a time.Time to creates a Value instance.
type Update ¶
Update is the UPDATE statement.
type Using ¶
type Using struct {
Tables []Table
}
Using is a USING clause.
type Value ¶
type Value struct {
Value interface{}
}
Value is an expression value.
func NewValueFromValuer ¶
NewValueFromValuer returns the underlying valuer value.
type Values ¶
type Values struct {
Values Expression
}
Values is a VALUES clause.
type Where ¶
type Where struct {
Condition Expression
}
Where is a WHERE clause.
func (Where) And ¶
func (where Where) And(right Expression) Where
And appends given Expression using AND as logical operator.
func (Where) Or ¶
func (where Where) Or(right Expression) Where
Or appends given Expression using OR as logical operator.