clause

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrimaryKey   string = "@@@py@@@" // primary key
	CurrentTable string = "@@@ct@@@" // current table
	Associations string = "@@@as@@@" // associations
)

Variables

View Source
var (
	PrimaryColumn = Column{Table: CurrentTable, Name: PrimaryKey}
)

Functions

func Cond

func Cond() *condExpr

Types

type AndConditions

type AndConditions struct {
	Exprs []Expression
}

func (AndConditions) Build

func (and AndConditions) Build(builder Builder)

type Assignment

type Assignment struct {
	Column Column
	Value  interface{}
}

type Builder

type Builder interface {
	Writer
	WriteQuoted(field interface{})
	AddVar(Writer, ...interface{})
}

Builder builder interface

type Clause

type Clause struct {
	Name                string // WHERE
	BeforeExpression    Expression
	AfterNameExpression Expression
	AfterExpression     Expression
	Expression          Expression
	Builder             ClauseBuilder
}

func (Clause) Build

func (c Clause) Build(builder Builder)

Build build clause

type ClauseBuilder

type ClauseBuilder func(Clause, Builder)

ClauseBuilder clause builder, allows to customize how to build clause

type Column

type Column struct {
	Table string
	Name  string
	Alias string
	Raw   bool
}

Column quote with name

type Delete

type Delete struct {
	Modifier string
}

func (Delete) Build

func (delete Delete) Build(builder Builder)

func (Delete) MergeClause

func (delete Delete) MergeClause(clause *Clause)

func (Delete) Name

func (delete Delete) Name() string

type EOp

type EOp int32
const (
	EqOp EOp = iota + 1
	NeqOp
	GtOp
	GteOp
	LtOp
	LteOp
	InOp
	LikeOp
)

type Eq

type Eq struct {
	Column interface{}
	Value  interface{}
}

Eq equal to for where

func (Eq) Build

func (eq Eq) Build(builder Builder)

func (Eq) NegationBuild

func (eq Eq) NegationBuild(builder Builder)

type Expr

type Expr struct {
	SQL                string
	Vars               []interface{}
	WithoutParentheses bool
}

Expr raw expression

func (Expr) Build

func (expr Expr) Build(builder Builder)

Build build raw expression

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 From

type From struct {
	Tables []Table
	Joins  []Join
}

From from clause

func (From) Build

func (from From) Build(builder Builder)

Build build from clause

func (From) MergeClause

func (from From) MergeClause(clause *Clause)

MergeClause merge from clause

func (From) Name

func (from From) Name() string

Name from clause name

type GroupBy

type GroupBy struct {
	Columns []Column
	Having  []Expression
}

GroupBy group by clause

func (GroupBy) Build

func (groupBy GroupBy) Build(builder Builder)

Build build group by clause

func (GroupBy) MergeClause

func (groupBy GroupBy) MergeClause(clause *Clause)

MergeClause merge group by clause

func (GroupBy) Name

func (groupBy GroupBy) Name() string

Name from clause name

type Gt

type Gt Eq

Gt greater than for where

func (Gt) Build

func (gt Gt) Build(builder Builder)

func (Gt) NegationBuild

func (gt Gt) NegationBuild(builder Builder)

type Gte

type Gte Eq

Gte greater than or equal to for where

func (Gte) Build

func (gte Gte) Build(builder Builder)

func (Gte) NegationBuild

func (gte Gte) NegationBuild(builder Builder)

type IN

type IN struct {
	Column interface{}
	Values []interface{}
}

IN Whether a value is within a set of values

func (IN) Build

func (in IN) Build(builder Builder)

func (IN) NegationBuild

func (in IN) NegationBuild(builder Builder)

type Insert

type Insert struct {
	Table    Table
	Modifier string
}

func (Insert) Build

func (insert Insert) Build(builder Builder)

Build build insert clause

func (Insert) MergeClause

func (insert Insert) MergeClause(clause *Clause)

MergeClause merge insert clause

func (Insert) Name

func (insert Insert) Name() string

Name insert clause name

type Interface

type Interface interface {
	Name() string
	Build(Builder)
	MergeClause(*Clause)
}

Interface clause interface

type Join

type Join struct {
	Type       JoinType
	Table      Table
	ON         Where
	Using      []string
	Expression Expression
}

Join join clause for from

func (Join) Build

func (join Join) Build(builder Builder)

type JoinType

type JoinType string
const (
	CrossJoin JoinType = "CROSS"
	InnerJoin JoinType = "INNER"
	LeftJoin  JoinType = "LEFT"
	RightJoin JoinType = "RIGHT"
)

type Like

type Like Eq

Like whether string matches regular expression

func (Like) Build

func (like Like) Build(builder Builder)

func (Like) NegationBuild

func (like Like) NegationBuild(builder Builder)

type Limit

type Limit struct {
	Limit  int
	Offset int
}

Limit limit clause

func (Limit) Build

func (limit Limit) Build(builder Builder)

Build build where clause

func (Limit) MergeClause

func (limit Limit) MergeClause(clause *Clause)

MergeClause merge order by clauses

func (Limit) Name

func (limit Limit) Name() string

Name where clause name

type Locking

type Locking struct {
	Strength string
	Table    Table
	Options  string
}

func (Locking) Build

func (locking Locking) Build(builder Builder)

Build build where clause

func (Locking) MergeClause

func (locking Locking) MergeClause(clause *Clause)

MergeClause merge order by clauses

func (Locking) Name

func (locking Locking) Name() string

Name where clause name

type Lt

type Lt Eq

Lt less than for where

func (Lt) Build

func (lt Lt) Build(builder Builder)

func (Lt) NegationBuild

func (lt Lt) NegationBuild(builder Builder)

type Lte

type Lte Eq

Lte less than or equal to for where

func (Lte) Build

func (lte Lte) Build(builder Builder)

func (Lte) NegationBuild

func (lte Lte) NegationBuild(builder Builder)

type NamedExpr

type NamedExpr struct {
	SQL  string
	Vars []interface{}
}

NamedExpr raw expression for named expr

func (NamedExpr) Build

func (expr NamedExpr) Build(builder Builder)

Build build raw expression

type NegationExpressionBuilder

type NegationExpressionBuilder interface {
	NegationBuild(builder Builder)
}

NegationExpressionBuilder negation expression builder

type Neq

type Neq Eq

Neq not equal to for where

func (Neq) Build

func (neq Neq) Build(builder Builder)

func (Neq) NegationBuild

func (neq Neq) NegationBuild(builder 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
	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) Build

func (orderBy OrderBy) Build(builder Builder)

Build build where clause

func (OrderBy) MergeClause

func (orderBy OrderBy) MergeClause(clause *Clause)

MergeClause merge order by clauses

func (OrderBy) Name

func (orderBy OrderBy) Name() string

Name where clause name

type OrderByColumn

type OrderByColumn struct {
	Column  Column
	Desc    bool
	Reorder bool
}

type Returning

type Returning struct {
	Columns []Column
}

func (Returning) Build

func (returning Returning) Build(builder Builder)

Build build where clause

func (Returning) MergeClause

func (returning Returning) MergeClause(clause *Clause)

MergeClause merge order by clauses

func (Returning) Name

func (returning Returning) Name() string

Name where clause name

type Select

type Select struct {
	Distinct   bool
	Columns    []Column
	Expression Expression
}

Select select attrs when querying, updating, creating

func (Select) Build

func (s Select) Build(builder Builder)

func (Select) MergeClause

func (s Select) MergeClause(clause *Clause)

func (Select) Name

func (s Select) Name() string

type Set

type Set []Assignment

func AssignmentColumns

func AssignmentColumns(values []string) Set

func Assignments

func Assignments(values map[string]interface{}) Set

func (Set) Build

func (set Set) Build(builder Builder)

func (Set) MergeClause

func (set Set) MergeClause(clause *Clause)

MergeClause merge assignment clauses

func (Set) Name

func (set Set) Name() string

type Table

type Table struct {
	Name  string
	Alias string
	Raw   bool
}

Table quote with name

type Update

type Update struct {
	Modifier string
	Table    Table
}

func (Update) Build

func (update Update) Build(builder Builder)

Build build update clause

func (Update) MergeClause

func (update Update) MergeClause(clause *Clause)

MergeClause merge update clause

func (Update) Name

func (update Update) Name() string

Name update clause name

type Values

type Values struct {
	Columns []Column
	Values  [][]interface{}
}

func (Values) Build

func (values Values) Build(builder Builder)

Build build from clause

func (Values) MergeClause

func (values Values) MergeClause(clause *Clause)

MergeClause merge values clauses

func (Values) Name

func (Values) Name() string

Name from clause name

type Where

type Where struct {
	Exprs []Expression
}

Where where clause

func (Where) Build

func (where Where) Build(builder Builder)

Build build where clause

func (Where) MergeClause

func (where Where) MergeClause(clause *Clause)

MergeClause merge where clauses

func (Where) Name

func (where Where) Name() string

Name where clause name

type Writer

type Writer interface {
	WriteByte(byte) error
	WriteString(string) (int, error)
}

Jump to

Keyboard shortcuts

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