Documentation
¶
Index ¶
- Constants
- Variables
- type AndConditions
- type Assigner
- type Assignment
- type Association
- type AssociationAssigner
- type AssociationOpType
- type Builder
- type Clause
- type ClauseBuilder
- type Column
- type CommaExpression
- type Delete
- type Eq
- type Expr
- type Expression
- type From
- type GroupBy
- type Gt
- type Gte
- type IN
- type Insert
- type Interface
- type Join
- type JoinTarget
- type JoinType
- type Like
- type Limit
- type Locking
- type Lt
- type Lte
- type NamedExpr
- type NegationExpressionBuilder
- type Neq
- type NotConditions
- type OnConflict
- type OrConditions
- type OrderBy
- type OrderByColumn
- type Returning
- type Select
- type Set
- type Table
- type Update
- type Values
- type Where
- type With
- type Writer
Constants ¶
const ( PrimaryKey string = "~~~py~~~" // primary key CurrentTable string = "~~~ct~~~" // current table Associations string = "~~~as~~~" // associations )
const ( LockingStrengthUpdate = "UPDATE" LockingOptionsSkipLocked = "SKIP LOCKED" LockingOptionsNoWait = "NOWAIT" )
const ( AndWithSpace = " AND " OrWithSpace = " OR " )
Variables ¶
var (
PrimaryColumn = Column{Table: CurrentTable, Name: PrimaryKey}
)
Functions ¶
This section is empty.
Types ¶
type AndConditions ¶
type AndConditions struct {
Exprs []Expression
}
func (AndConditions) Build ¶
func (and AndConditions) Build(builder Builder)
type Assigner ¶ added in v1.30.5
type Assigner interface {
Assignments() []Assignment
}
Assigner assignments provider interface
type Assignment ¶
type Assignment struct {
Column Column
Value interface{}
}
func (Assignment) Assignments ¶ added in v1.30.5
func (a Assignment) Assignments() []Assignment
Assignments implements Assigner for a single Assignment.
type Association ¶ added in v1.31.0
type Association struct {
Association string // Association name
Type AssociationOpType // Operation type
Conditions []Expression // Filter conditions
Set []Assignment // Assignment operations (for Update and Create)
Values []interface{} // Values for Create operation
}
Association represents an association operation
func (Association) Assignments ¶ added in v1.31.0
func (ao Association) Assignments() []Assignment
Assignments implements the Assigner interface so that AssociationOperation can be used as a Set method parameter
func (Association) AssociationAssignments ¶ added in v1.31.0
func (ao Association) AssociationAssignments() []Association
AssociationAssignments implements the AssociationAssigner interface
type AssociationAssigner ¶ added in v1.31.0
type AssociationAssigner interface {
AssociationAssignments() []Association
}
AssociationAssigner is an interface for association operation providers
type AssociationOpType ¶ added in v1.31.0
type AssociationOpType int
AssociationOpType represents association operation types
const ( OpUnlink AssociationOpType = iota // Unlink association OpDelete // Delete association records OpUpdate // Update association records OpCreate // Create association records with assignments )
type Builder ¶
type Builder interface {
Writer
WriteQuoted(field interface{})
AddVar(Writer, ...interface{})
AddError(error) error
}
Builder builder interface
type Clause ¶
type Clause struct {
Name string // WHERE
BeforeExpression Expression
AfterNameExpression Expression
AfterExpression Expression
Expression Expression
Builder ClauseBuilder
}
Clause
type ClauseBuilder ¶
ClauseBuilder clause builder, allows to customize how to build clause
type CommaExpression ¶ added in v1.21.13
type CommaExpression struct {
Exprs []Expression
}
CommaExpression represents a group of expressions separated by commas.
func (CommaExpression) Build ¶ added in v1.21.13
func (comma CommaExpression) Build(builder Builder)
type Eq ¶
type Eq struct {
Column interface{}
Value interface{}
}
Eq equal to for where
func (Eq) NegationBuild ¶
type Expression ¶
type Expression interface {
Build(builder Builder)
}
Expression expression interface
func And ¶
func And(exprs ...Expression) Expression
func Not ¶
func Not(exprs ...Expression) Expression
func Or ¶
func Or(exprs ...Expression) Expression
type GroupBy ¶
type GroupBy struct {
Columns []Column
Having []Expression
}
GroupBy group by clause
func (GroupBy) MergeClause ¶
MergeClause merge group by clause
type IN ¶
type IN struct {
Column interface{}
Values []interface{}
}
IN Whether a value is within a set of values
func (IN) NegationBuild ¶
type Insert ¶
func (Insert) MergeClause ¶
MergeClause merge insert clause
type Join ¶
type Join struct {
Type JoinType
Table Table
ON Where
Using []string
Expression Expression
}
Join clause for from
type JoinTarget ¶ added in v1.30.0
type JoinTarget struct {
Type JoinType
Association string
Subquery Expression
Table string
}
func Has ¶ added in v1.30.0
func Has(name string) JoinTarget
func (JoinTarget) As ¶ added in v1.30.0
func (jt JoinTarget) As(name string) JoinTarget
type JoinType ¶
type JoinType string
func (JoinType) Association ¶ added in v1.30.0
func (jt JoinType) Association(name string) JoinTarget
func (JoinType) AssociationFrom ¶ added in v1.30.0
func (jt JoinType) AssociationFrom(name string, subquery Expression) JoinTarget
type Locking ¶
func (Locking) MergeClause ¶ added in v0.2.4
MergeClause merge order by clauses
type NamedExpr ¶ added in v0.2.21
type NamedExpr struct {
SQL string
Vars []interface{}
}
NamedExpr raw expression for named expr
type NegationExpressionBuilder ¶
type NegationExpressionBuilder interface {
NegationBuild(builder Builder)
}
NegationExpressionBuilder negation expression builder
type NotConditions ¶
type NotConditions struct {
Exprs []Expression
}
func (NotConditions) Build ¶
func (not NotConditions) Build(builder Builder)
type OnConflict ¶
type OnConflict struct {
Columns []Column
Where Where
TargetWhere Where
OnConstraint string
DoNothing bool
DoUpdates Set
UpdateAll bool
}
func (OnConflict) Build ¶
func (onConflict OnConflict) Build(builder Builder)
Build build onConflict clause
func (OnConflict) MergeClause ¶
func (onConflict OnConflict) MergeClause(clause *Clause)
MergeClause merge onConflict clauses
func (OnConflict) Name ¶
func (OnConflict) Name() string
type OrConditions ¶
type OrConditions struct {
Exprs []Expression
}
func (OrConditions) Build ¶
func (or OrConditions) Build(builder Builder)
type OrderBy ¶
type OrderBy struct {
Columns []OrderByColumn
Expression Expression
}
func (OrderBy) MergeClause ¶
MergeClause merge order by clauses
type OrderByColumn ¶
type Returning ¶
type Returning struct {
Columns []Column
}
func (Returning) MergeClause ¶
MergeClause merge order by clauses
type Select ¶
type Select struct {
Distinct bool
Columns []Column
Expression Expression
}
Select select attrs when querying, updating, creating
func (Select) MergeClause ¶
type Set ¶
type Set []Assignment
func AssignmentColumns ¶ added in v0.2.5
func Assignments ¶ added in v0.2.4
func (Set) Assignments ¶ added in v1.30.5
func (set Set) Assignments() []Assignment
Assignments implements Assigner for Set.
func (Set) MergeClause ¶
MergeClause merge assignments clauses
type Update ¶
func (Update) MergeClause ¶
MergeClause merge update clause
type Values ¶
type Values struct {
Columns []Column
Values [][]interface{}
}
func (Values) MergeClause ¶
MergeClause merge values clauses
type Where ¶
type Where struct {
Exprs []Expression
}
Where where clause
func (Where) MergeClause ¶
MergeClause merge where clauses