iclause

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Union     = "UNION"
	Intersect = "INTERSECT"
	Except    = "EXCEPT"
)
View Source
const (
	SearchBreadth = "BREADTH"
	SearchDepth   = "DEPTH"
)

Variables

View Source
var ErrNoCombinationStrategy = errors.New("Combination strategy must be set")

Functions

This section is empty.

Types

type CTE

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

func (*CTE) SetMaterialized

func (c *CTE) SetMaterialized()

func (*CTE) SetNotMaterialized

func (c *CTE) SetNotMaterialized()

func (*CTE) SetQuery

func (c *CTE) SetQuery(q litsql.Query)

func (*CTE) WriteSQL

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

type CTECycle

type CTECycle struct {
	Columns    []string
	Set        string
	Using      string
	SetVal     litsql.Expression
	DefaultVal litsql.Expression
}

func (*CTECycle) WriteSQL

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

type CTESearch

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

func (*CTESearch) WriteSQL

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

type Columns

type Columns struct {
	Columns []litsql.Expression
}

func (*Columns) ClauseID added in v0.2.0

func (c *Columns) ClauseID() string

func (*Columns) ClauseMerge

func (c *Columns) ClauseMerge(other litsql.QueryClause)

func (*Columns) ClauseOrder

func (c *Columns) ClauseOrder() int

func (*Columns) WriteSQL

func (c *Columns) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Combine

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

func (*Combine) ClauseID added in v0.2.0

func (c *Combine) ClauseID() string

func (*Combine) ClauseMultiple

func (s *Combine) ClauseMultiple()

func (*Combine) ClauseOrder

func (s *Combine) ClauseOrder() int

func (*Combine) WriteSQL

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

type DeleteFrom

type DeleteFrom struct {
	Table string
}

func (*DeleteFrom) ClauseID added in v0.2.0

func (c *DeleteFrom) ClauseID() string

func (*DeleteFrom) ClauseOrder

func (c *DeleteFrom) ClauseOrder() int

func (*DeleteFrom) WriteSQL

func (c *DeleteFrom) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type DeleteOnly

type DeleteOnly struct {
	Only bool
}

func (*DeleteOnly) ClauseID added in v0.2.0

func (c *DeleteOnly) ClauseID() string

func (*DeleteOnly) ClauseOrder

func (c *DeleteOnly) ClauseOrder() int

func (*DeleteOnly) WriteSQL

func (c *DeleteOnly) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Distinct

type Distinct struct {
	On []litsql.Expression
}

func (*Distinct) ClauseID added in v0.2.0

func (c *Distinct) ClauseID() string

func (*Distinct) ClauseMerge

func (c *Distinct) ClauseMerge(other litsql.QueryClause)

func (*Distinct) ClauseOrder

func (c *Distinct) ClauseOrder() int

func (*Distinct) WriteSQL

func (c *Distinct) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Frame

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

func (*Frame) SetEnd

func (f *Frame) SetEnd(end litsql.Expression)

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 litsql.Expression)

func (*Frame) WriteSQL

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

type From

type From struct {
	Table   litsql.Expression
	Starter bool
	Clause  string

	// Aliases
	Alias   string
	Columns []string

	// Dialect specific modifiers
	Only           bool // Postgres
	Lateral        bool // Postgres & MySQL
	WithOrdinality bool // Postgres
}

func (*From) ClauseID added in v0.2.0

func (c *From) ClauseID() string

func (*From) ClauseOrder

func (c *From) ClauseOrder() int

func (*From) SetAs

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

func (*From) SetLateral

func (f *From) SetLateral()

func (*From) SetOnly

func (f *From) SetOnly()

func (*From) SetWithOrdinality

func (f *From) SetWithOrdinality()

func (*From) WriteSQL

func (c *From) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type GroupBy

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

func (*GroupBy) ClauseID added in v0.2.0

func (c *GroupBy) ClauseID() string

func (*GroupBy) ClauseMerge

func (c *GroupBy) ClauseMerge(other litsql.QueryClause)

func (*GroupBy) ClauseOrder

func (c *GroupBy) ClauseOrder() int

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 litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Having

type Having struct {
	Conditions []litsql.Expression
}

func (*Having) ClauseID added in v0.2.0

func (c *Having) ClauseID() string

func (*Having) ClauseMerge

func (c *Having) ClauseMerge(other litsql.QueryClause)

func (*Having) ClauseOrder

func (c *Having) ClauseOrder() int

func (*Having) WriteSQL

func (c *Having) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type InsertConflict

type InsertConflict struct {
	Do     string // DO NOTHING | DO UPDATE
	Target InsertConflictTarget
	Set    Set
	Where  Where
}

func (*InsertConflict) ClauseID added in v0.2.0

func (c *InsertConflict) ClauseID() string

func (*InsertConflict) ClauseOrder

func (c *InsertConflict) ClauseOrder() int

func (*InsertConflict) SetDoNothing

func (c *InsertConflict) SetDoNothing()

func (*InsertConflict) SetDoUpdate

func (c *InsertConflict) SetDoUpdate()

func (*InsertConflict) SetWhere

func (c *InsertConflict) SetWhere(condition litsql.Expression)

func (InsertConflict) WriteSQL

func (c InsertConflict) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type InsertConflictTarget

type InsertConflictTarget struct {
	Constraint string
	Columns    []string
	Where      []litsql.Expression
}

func (*InsertConflictTarget) WriteSQL

func (c *InsertConflictTarget) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type InsertOverriding

type InsertOverriding struct {
	Overriding string
}

func (*InsertOverriding) ClauseID added in v0.2.0

func (c *InsertOverriding) ClauseID() string

func (*InsertOverriding) ClauseOrder

func (c *InsertOverriding) ClauseOrder() int

func (*InsertOverriding) WriteSQL

func (c *InsertOverriding) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Join

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

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

func (*Join) ClauseID added in v0.2.0

func (c *Join) ClauseID() string

func (*Join) ClauseMultiple

func (c *Join) ClauseMultiple()

func (*Join) ClauseOrder

func (c *Join) ClauseOrder() int

func (*Join) SetNatural

func (c *Join) SetNatural()

func (*Join) SetOn

func (c *Join) SetOn(on string)

func (*Join) SetOnC

func (c *Join) SetOnC(query string, args ...any)

func (*Join) SetOnE

func (c *Join) SetOnE(on litsql.Expression)

func (*Join) SetUsing

func (c *Join) SetUsing(using ...string)

func (*Join) WriteSQL

func (c *Join) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Limit

type Limit struct {
	Count litsql.Expression
}

func (*Limit) ClauseID added in v0.2.0

func (c *Limit) ClauseID() string

func (*Limit) ClauseOrder

func (c *Limit) ClauseOrder() int

func (*Limit) WriteSQL

func (c *Limit) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type NamedWindow

type NamedWindow struct {
	Name       string
	Definition WindowDef
}

func (NamedWindow) WriteSQL

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

type Offset

type Offset struct {
	Count litsql.Expression
}

func (*Offset) ClauseID added in v0.2.0

func (c *Offset) ClauseID() string

func (*Offset) ClauseOrder

func (c *Offset) ClauseOrder() int

func (*Offset) WriteSQL

func (c *Offset) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type OrderBy

type OrderBy struct {
	Expressions []litsql.Expression
}

func (*OrderBy) ClauseID added in v0.2.0

func (c *OrderBy) ClauseID() string

func (*OrderBy) ClauseMerge

func (c *OrderBy) ClauseMerge(other litsql.QueryClause)

func (*OrderBy) ClauseOrder

func (c *OrderBy) ClauseOrder() int

func (*OrderBy) WriteSQL

func (c *OrderBy) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Returning

type Returning struct {
	Expressions []litsql.Expression
}

func (*Returning) ClauseID added in v0.2.0

func (c *Returning) ClauseID() string

func (*Returning) ClauseMerge

func (c *Returning) ClauseMerge(other litsql.QueryClause)

func (*Returning) ClauseOrder

func (c *Returning) ClauseOrder() int

func (*Returning) WriteSQL

func (c *Returning) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Set

type Set struct {
	Set     []litsql.Expression
	Starter bool
}

func (*Set) ClauseID added in v0.2.0

func (c *Set) ClauseID() string

func (*Set) ClauseMerge

func (c *Set) ClauseMerge(other litsql.QueryClause)

func (*Set) ClauseOrder

func (c *Set) ClauseOrder() int

func (*Set) WriteSQL

func (c *Set) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Table

type Table struct {
	Expression litsql.Expression
	Alias      string
	Columns    []string
}

func (*Table) ClauseID added in v0.2.0

func (c *Table) ClauseID() string

func (*Table) ClauseOrder

func (c *Table) ClauseOrder() int

func (*Table) WriteSQL

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

type UpdateOnly

type UpdateOnly struct {
	Only bool
}

func (*UpdateOnly) ClauseID added in v0.2.0

func (c *UpdateOnly) ClauseID() string

func (*UpdateOnly) ClauseOrder

func (c *UpdateOnly) ClauseOrder() int

func (*UpdateOnly) WriteSQL

func (c *UpdateOnly) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Value

type Value []litsql.Expression

func (Value) WriteSQL

func (v Value) WriteSQL(w litsql.Writer, d litsql.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 litsql.Query

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

func (*Values) ClauseID added in v0.2.0

func (c *Values) ClauseID() string

func (*Values) ClauseMerge

func (c *Values) ClauseMerge(other litsql.QueryClause)

func (*Values) ClauseOrder

func (c *Values) ClauseOrder() int

func (*Values) WriteSQL

func (c *Values) WriteSQL(w litsql.Writer, d litsql.Dialect, start int) ([]any, error)

type Where

type Where struct {
	Conditions []litsql.Expression
}

func (*Where) ClauseID added in v0.2.0

func (c *Where) ClauseID() string

func (*Where) ClauseMerge

func (c *Where) ClauseMerge(other litsql.QueryClause)

func (*Where) ClauseOrder

func (c *Where) ClauseOrder() int

func (*Where) WriteSQL

func (c *Where) WriteSQL(w litsql.Writer, d litsql.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 ...litsql.Expression)

func (*WindowDef) AddPartitionBy

func (wi *WindowDef) AddPartitionBy(condition ...litsql.Expression)

func (*WindowDef) SetFrom

func (wi *WindowDef) SetFrom(from string)

func (*WindowDef) WriteSQL

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

type Windows

type Windows struct {
	Windows []NamedWindow
}

func (*Windows) ClauseID added in v0.2.0

func (c *Windows) ClauseID() string

func (*Windows) ClauseMerge

func (wi *Windows) ClauseMerge(other litsql.QueryClause)

func (*Windows) ClauseOrder

func (wi *Windows) ClauseOrder() int

func (*Windows) WriteSQL

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

type With

type With struct {
	Recursive bool
	CTEs      []*CTE
}

func (*With) ClauseID added in v0.2.0

func (c *With) ClauseID() string

func (*With) ClauseMerge

func (c *With) ClauseMerge(other litsql.QueryClause)

func (*With) ClauseOrder

func (c *With) ClauseOrder() int

func (*With) SetRecursive

func (w *With) SetRecursive(r bool)

func (*With) WriteSQL

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

Jump to

Keyboard shortcuts

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