clause

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 6 Imported by: 17

Documentation

Index

Constants

View Source
const (
	Union     = "UNION"
	Intersect = "INTERSECT"
	Except    = "EXCEPT"
)
View Source
const (
	SearchBreadth = "BREADTH"
	SearchDepth   = "DEPTH"
)
View Source
const (
	LockStrengthUpdate      = "UPDATE"
	LockStrengthNoKeyUpdate = "NO KEY UPDATE"
	LockStrengthShare       = "SHARE"
	LockStrengthKeyShare    = "KEY SHARE"
)
View Source
const (
	LockWaitNoWait     = "NOWAIT"
	LockWaitSkipLocked = "SKIP LOCKED"
)
View Source
const (
	InnerJoin    = "INNER JOIN"
	LeftJoin     = "LEFT JOIN"
	RightJoin    = "RIGHT JOIN"
	FullJoin     = "FULL JOIN"
	CrossJoin    = "CROSS JOIN"
	StraightJoin = "STRAIGHT_JOIN"
)

Variables

View Source
var ErrNoCombinationStrategy = errors.New("Combination strategy must be set")
View Source
var ErrNoLockStrength = errors.New("No lock strength specified")

Functions

This section is empty.

Types

type CTE

type CTE struct {
	Query        bob.Query // SQL standard says only select, postgres allows insert/update/delete
	Name         string
	Columns      []string
	Materialized *bool
	Search       CTESearch
	Cycle        CTECycle
}

func (CTE) WriteSQL

func (c CTE) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type CTECycle

type CTECycle struct {
	Columns    []string
	Set        string
	Using      string
	SetVal     any
	DefaultVal any
}

func (CTECycle) WriteSQL

func (c CTECycle) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type CTESearch

type CTESearch struct {
	Order   string
	Columns []string
	Set     string
}

func (CTESearch) WriteSQL

func (c CTESearch) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Combine

type Combine struct {
	Strategy string
	Query    bob.Query
	All      bool
}

func (*Combine) SetCombine

func (s *Combine) SetCombine(c Combine)

func (Combine) WriteSQL

func (s Combine) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Conflict

type Conflict struct {
	Do     string // DO NOTHING | DO UPDATE
	Target ConflictTarget
	Set
	Where
}

func (*Conflict) SetConflict

func (c *Conflict) SetConflict(conflict Conflict)

func (Conflict) WriteSQL

func (c Conflict) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type ConflictTarget

type ConflictTarget struct {
	Constraint string
	Columns    []any
	Where      []any
}

func (ConflictTarget) WriteSQL

func (c ConflictTarget) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Fetch

type Fetch struct {
	Count    *int64
	WithTies bool
}

func (*Fetch) SetFetch

func (f *Fetch) SetFetch(fetch Fetch)

func (Fetch) WriteSQL

func (f Fetch) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type For

type For struct {
	Strength string
	Tables   []string
	Wait     string
}

func (*For) SetFor

func (f *For) SetFor(lock For)

func (For) WriteSQL

func (f For) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Frame

type Frame struct {
	Defined   bool // whether any of the parts was defined
	Mode      string
	Start     any
	End       any    // can be nil
	Exclusion string // can be empty
}

func (*Frame) SetEnd

func (f *Frame) SetEnd(end any)

func (*Frame) SetExclusion

func (f *Frame) SetExclusion(excl string)

func (*Frame) SetMode

func (f *Frame) SetMode(mode string)

func (*Frame) SetStart

func (f *Frame) SetStart(start any)

func (Frame) WriteSQL

func (f Frame) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type From added in v0.2.0

type From struct {
	Table any

	// Aliases
	Alias   string
	Columns []string

	// Dialect specific modifiers
	Only           bool        // Postgres
	Lateral        bool        // Postgres & MySQL
	WithOrdinality bool        // Postgres
	IndexedBy      *string     // SQLite
	Partitions     []string    // MySQL
	IndexHints     []IndexHint // MySQL

	// Joins
	Joins []Join
}

func (*From) AppendIndexHint added in v0.2.0

func (f *From) AppendIndexHint(i IndexHint)

func (*From) AppendJoin added in v0.2.0

func (f *From) AppendJoin(j Join)

func (*From) AppendPartition added in v0.2.0

func (f *From) AppendPartition(partitions ...string)

func (*From) SetIndexedBy added in v0.2.0

func (f *From) SetIndexedBy(i *string)

func (*From) SetLateral added in v0.2.0

func (f *From) SetLateral(lateral bool)

func (*From) SetOnly added in v0.2.0

func (f *From) SetOnly(only bool)

func (*From) SetTable added in v0.2.0

func (f *From) SetTable(table any)

func (*From) SetTableAlias added in v0.2.0

func (f *From) SetTableAlias(alias string, columns ...string)

func (*From) SetWithOrdinality added in v0.2.0

func (f *From) SetWithOrdinality(to bool)

func (From) WriteSQL added in v0.2.0

func (f From) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type GroupBy

type GroupBy struct {
	Groups   []any
	Distinct bool
	With     string // ROLLUP | CUBE
}

func (*GroupBy) AppendGroup

func (g *GroupBy) AppendGroup(e any)

func (*GroupBy) SetGroupByDistinct

func (g *GroupBy) SetGroupByDistinct(distinct bool)

func (*GroupBy) SetGroupWith

func (g *GroupBy) SetGroupWith(with string)

func (GroupBy) WriteSQL

func (g GroupBy) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type GroupingSet

type GroupingSet struct {
	Groups []bob.Expression
	Type   string // GROUPING SET | CUBE | ROLLUP
}

func (GroupingSet) WriteSQL

func (g GroupingSet) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Having

type Having struct {
	Conditions []any
}

func (*Having) AppendHaving

func (h *Having) AppendHaving(e ...any)

func (Having) WriteSQL

func (h Having) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type IWindow

type IWindow interface {
	SetFrom(string)
	AddPartitionBy(...any)
	AddOrderBy(...any)
	SetMode(string)
	SetStart(any)
	SetEnd(any)
	SetExclusion(string)
}

type IndexHint

type IndexHint struct {
	Type    string // USE, FORCE or IGNORE
	Indexes []string
	For     string // JOIN, ORDER BY or GROUP BY
}

func (IndexHint) WriteSQL

func (f IndexHint) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Join

type Join struct {
	Type string
	To   From // the expression for the table

	// Join methods
	Natural bool
	On      []bob.Expression
	Using   []string
}

func (Join) WriteSQL

func (j Join) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Limit

type Limit struct {
	// Some DBs (e.g. SQite) can take an expression
	// It is up to the mods to enforce any extra conditions
	Count any
}

func (*Limit) SetLimit

func (l *Limit) SetLimit(limit any)

func (Limit) WriteSQL

func (l Limit) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type NamedWindow

type NamedWindow struct {
	Name       string
	Definition any
}

func (NamedWindow) WriteSQL

func (n NamedWindow) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Offset

type Offset struct {
	// Some DBs (e.g. SQite) can take an expression
	// It is up to the mods to enforce any extra conditions
	Count any
}

func (*Offset) SetOffset

func (o *Offset) SetOffset(offset any)

func (Offset) WriteSQL

func (o Offset) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type OrderBy

type OrderBy struct {
	Expressions []OrderDef
}

func (*OrderBy) AppendOrder

func (o *OrderBy) AppendOrder(order OrderDef)

func (OrderBy) WriteSQL

func (o OrderBy) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type OrderDef

type OrderDef struct {
	Expression    any
	Direction     string // ASC | DESC | USING operator
	Nulls         string // FIRST | LAST
	CollationName string
}

func (OrderDef) WriteSQL

func (o OrderDef) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Returning

type Returning struct {
	Expressions []any
}

func (*Returning) AppendReturning

func (r *Returning) AppendReturning(columns ...any)

func (*Returning) HasReturning added in v0.22.0

func (r *Returning) HasReturning() bool

func (Returning) WriteSQL

func (r Returning) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type SelectList added in v0.7.0

type SelectList struct {
	Columns []any
	// necessary to be able to treat preloaders
	// like any other query Mod
	PreloadColumns []any
}

func (*SelectList) AppendPreloadSelect added in v0.20.0

func (s *SelectList) AppendPreloadSelect(columns ...any)

func (*SelectList) AppendSelect added in v0.7.0

func (s *SelectList) AppendSelect(columns ...any)

func (*SelectList) CountSelectCols added in v0.20.0

func (s *SelectList) CountSelectCols() int

func (*SelectList) SetSelect added in v0.20.0

func (s *SelectList) SetSelect(columns ...any)

func (SelectList) WriteSQL added in v0.7.0

func (s SelectList) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Set

type Set struct {
	Set []any
}

func (*Set) AppendSet

func (s *Set) AppendSet(exprs ...any)

func (Set) WriteSQL

func (s Set) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Table

type Table struct {
	Expression any
	Alias      string
	Columns    []string

	Partitions []string // MySQL
}

func (Table) As

func (t Table) As(alias string, columns ...string) Table

func (Table) WriteSQL

func (t Table) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Values

type Values struct {
	// Query takes the highest priority
	// If present, will attempt to insert from this query
	Query bob.Query

	// for multiple inserts
	// each sub-slice is one set of values
	Vals []value
}

func (*Values) AppendValues

func (v *Values) AppendValues(vals ...bob.Expression)

func (Values) WriteSQL

func (v Values) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Where

type Where struct {
	Conditions []any
}

func (*Where) AppendWhere

func (wh *Where) AppendWhere(e ...any)

func (Where) WriteSQL

func (wh Where) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type WindowDef

type WindowDef struct {
	From string // an existing window name

	Frame
	// contains filtered or unexported fields
}

func (*WindowDef) AddOrderBy

func (wi *WindowDef) AddOrderBy(order ...any)

func (*WindowDef) AddPartitionBy

func (wi *WindowDef) AddPartitionBy(condition ...any)

func (*WindowDef) SetFrom

func (wi *WindowDef) SetFrom(from string)

func (WindowDef) Valid added in v0.7.1

func (wi WindowDef) Valid() bool

func (WindowDef) WriteSQL

func (wi WindowDef) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Windows

type Windows struct {
	Windows []NamedWindow
}

func (*Windows) AppendWindow

func (wi *Windows) AppendWindow(w NamedWindow)

func (Windows) WriteSQL

func (wi Windows) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type With

type With struct {
	Recursive bool
	CTEs      []CTE
}

func (*With) AppendWith

func (w *With) AppendWith(cte CTE)

func (*With) SetRecursive

func (w *With) SetRecursive(r bool)

func (With) WriteSQL

func (w With) WriteSQL(wr io.Writer, d bob.Dialect, start int) ([]any, error)

Jump to

Keyboard shortcuts

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