builder

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFromItemLateralAndOnly = errors.New("from item: cannot specify both LATERAL and ONLY")
View Source
var ErrInsertConflictConstraintAndTarget = errors.New("insert: cannot set both conflict constraint name and targets")
View Source
var ErrInsertValuesAndQuery = errors.New("insert: cannot set both values and query")
View Source
var ErrInvalidIdentifier = errors.New("identifier: invalid")
View Source
var ErrNoConditionsGiven = errors.New("case: no conditions given")

Functions

This section is empty.

Types

type AggExpBuilder

type AggExpBuilder struct {
	ExpBase
	// contains filtered or unexported fields
}

func Agg

func Agg(name string, exps []Exp) AggExpBuilder

func (AggExpBuilder) Distinct

func (b AggExpBuilder) Distinct() AggExpBuilder

func (AggExpBuilder) Filter

func (b AggExpBuilder) Filter(cond Exp) AggExpBuilder

Filter adds a filter to the aggregate function. Multiple calls to Filter are joined with AND.

func (AggExpBuilder) IsExp

func (b AggExpBuilder) IsExp()

func (AggExpBuilder) OrderBy

func (b AggExpBuilder) OrderBy(exp Exp) OrderByAggExpBuilder

OrderBy adds an ORDER BY clause to the aggregate function. If AggExpBuilder.WithinGroup is called, the ORDER BY clause is used after the aggregate function in WITHIN GROUP.

func (AggExpBuilder) WithinGroup

func (b AggExpBuilder) WithinGroup() AggExpBuilder

WithinGroup adds a WITHIN GROUP order by clause after the aggregate function. Sort arguments are added via AggExpBuilder.OrderBy.

func (AggExpBuilder) WriteSQL

func (b AggExpBuilder) WriteSQL(sb *SQLBuilder)

type CaseBuilder

type CaseBuilder struct {
	// contains filtered or unexported fields
}

func Case

func Case(exp ...Exp) CaseBuilder

func (CaseBuilder) Else

func (b CaseBuilder) Else(result Exp) CaseBuilder

func (CaseBuilder) End

func (b CaseBuilder) End() CaseExp

func (CaseBuilder) When

func (b CaseBuilder) When(condition Exp) CaseWhenBuilder

type CaseExp

type CaseExp struct {
	ExpBase
	// contains filtered or unexported fields
}

func (CaseExp) WriteSQL

func (c CaseExp) WriteSQL(sb *SQLBuilder)

type CaseWhenBuilder

type CaseWhenBuilder struct {
	// contains filtered or unexported fields
}

func (CaseWhenBuilder) Then

func (b CaseWhenBuilder) Then(result Exp) CaseBuilder

type CombinationBuilder

type CombinationBuilder struct {
	SelectBuilder
}

func (CombinationBuilder) All

type DeleteBuilder

type DeleteBuilder struct {
	// contains filtered or unexported fields
}

func DeleteFrom

func DeleteFrom(tableName Identer) DeleteBuilder

func (DeleteBuilder) As

func (b DeleteBuilder) As(alias string) DeleteBuilder

func (DeleteBuilder) Returning added in v0.2.0

func (b DeleteBuilder) Returning(outputExpression Exp) ReturningDeleteBuilder

func (DeleteBuilder) Using added in v0.2.0

func (b DeleteBuilder) Using(from FromExp) FromDeleteBuilder

Using adds a USING clause to the delete.

func (DeleteBuilder) Where

func (b DeleteBuilder) Where(cond Exp) DeleteBuilder

Where adds a WHERE condition to the delete. Multiple calls to Where are joined with AND.

func (DeleteBuilder) WriteSQL

func (b DeleteBuilder) WriteSQL(sb *SQLBuilder)

type Exp

type Exp interface {
	IsExp()
	SQLWriter
}

func And

func And(exps ...Exp) Exp

And builds an AND expression of non-nil expressions.

func Array

func Array(elems ...Exp) Exp

Array builds an array literal.

Make sure that all elements are of the same type.

func Bool

func Bool(b bool) Exp

func Default

func Default() Exp

Default builds the DEFAULT keyword.

func Exists added in v0.2.0

func Exists(subquery SelectExp) Exp

func Float

func Float(f float64) Exp

func Int

func Int(s int) Exp

func Interval

func Interval(spec string) Exp

Interval builds an interval constant.

func Not

func Not(e Exp) Exp

Not builds a NOT expression.

func Null

func Null() Exp

Null builds the NULL literal.

func Or

func Or(exps ...Exp) Exp

Or builds an OR expression of non-nil expressions.

func String

func String(s string) Exp

type ExpBase

type ExpBase struct {
	Exp
}

ExpBase is a base type for expressions to allow embedding of various default operators.

func Arg

func Arg(argument any) ExpBase

Arg creates an expression that represents an argument that will be bound to a placeholder with the given value. Each call to Arg will create a new placeholder and emit the argument when writing the query.

func Bind

func Bind(argName string) ExpBase

Bind creates an expression that represents an argument that will be bound to a placeholder with the given value. If Bind is called again with the same name, the same placeholder will be used.

func Coalesce

func Coalesce(exp Exp, rest ...Exp) ExpBase

func FuncExp

func FuncExp(name string, args []Exp) ExpBase

func Greatest

func Greatest(exp Exp, rest ...Exp) ExpBase

func Least

func Least(exp Exp, rest ...Exp) ExpBase

func Neg added in v0.2.1

func Neg(exp Exp) ExpBase

Neg builds the - unary operator (negation) for numeric types.

func NullIf

func NullIf(value1, value2 Exp) ExpBase

func (ExpBase) Cast

func (b ExpBase) Cast(typ string) ExpBase

func (ExpBase) Concat

func (b ExpBase) Concat(rgt Exp) ExpBase

func (ExpBase) ContainedBy added in v0.2.4

func (b ExpBase) ContainedBy(rgt Exp) ExpBase

func (ExpBase) Contains added in v0.2.4

func (b ExpBase) Contains(rgt Exp) ExpBase

func (ExpBase) Divide added in v0.2.1

func (b ExpBase) Divide(rgt Exp) ExpBase

Divide builds the / operator (division) for numeric types. Do not confuse with the div function that returns the integer part of the division.

func (ExpBase) Eq

func (b ExpBase) Eq(rgt Exp) Exp

func (ExpBase) Gt

func (b ExpBase) Gt(rgt Exp) Exp

func (ExpBase) Gte

func (b ExpBase) Gte(rgt Exp) Exp

func (ExpBase) ILike

func (b ExpBase) ILike(rgt Exp) MatchingBuilder

func (ExpBase) In added in v0.2.0

func (b ExpBase) In(selectOrExpressions SelectOrExpressions) Exp

func (ExpBase) IsExp

func (ExpBase) IsExp()

func (ExpBase) IsNotNull

func (b ExpBase) IsNotNull() Exp

IsNotNull builds an IS NOT NULL expression.

func (ExpBase) IsNull

func (b ExpBase) IsNull() Exp

IsNull builds an IS NULL expression.

func (ExpBase) JsonExtract

func (b ExpBase) JsonExtract(rgt Exp) ExpBase

JsonExtract builds the -> operator for json / jsonb.

json -> text → json
jsonb -> text → jsonb

Extracts JSON object field with the given key.

json -> integer → json
jsonb -> integer → jsonb

Extracts nth element of JSON array (array elements are indexed from zero, but negative integers count from the end).

func (ExpBase) JsonExtractPath

func (b ExpBase) JsonExtractPath(rgt Exp) ExpBase

JsonExtractPath builds the #> operator for json / jsonb.

json #> text[] → json
jsonb #> text[] → jsonb

Extracts JSON sub-object at the specified path, where path elements can be either field keys or array indexes.

Example:

fn.JsonExtractPath(qrb.String(`{"a": {"b": ["foo","bar"]}}`).Cast("jsonb"), qrb.Array(qrb.String("a"), qrb.String("b")))

func (ExpBase) JsonExtractPathText

func (b ExpBase) JsonExtractPathText(rgt Exp) ExpBase

JsonExtractPathText builds the #>> operator for json / jsonb.

json #>> text[] → text
jsonb #>> text[] → text

Extracts JSON sub-object at the specified path as text.

Example:

fn.JsonExtractPathText(qrb.String(`{"a": {"b": ["foo","bar"]}}`).Cast("jsonb"), qrb.Array(qrb.String("a"), qrb.String("b"), qrb.String("1)))

func (ExpBase) JsonExtractText

func (b ExpBase) JsonExtractText(rgt Exp) ExpBase

JsonExtractText builds the ->> operator for json / jsonb.

json ->> text → text
jsonb ->> text → text

Extracts JSON object field with the given key, as text.

json ->> integer → text
jsonb ->> integer → text

Extracts nth element of JSON array, as text.

func (ExpBase) Like

func (b ExpBase) Like(rgt Exp) MatchingBuilder

func (ExpBase) Lt

func (b ExpBase) Lt(rgt Exp) Exp

func (ExpBase) Lte

func (b ExpBase) Lte(rgt Exp) Exp

func (ExpBase) Minus added in v0.2.1

func (b ExpBase) Minus(rgt Exp) ExpBase

Minus builds the - operator (subtraction) for numeric types.

func (ExpBase) Mod added in v0.2.1

func (b ExpBase) Mod(rgt Exp) ExpBase

Mod builds the % operator (remainder) for numeric types.

func (ExpBase) Mult added in v0.2.1

func (b ExpBase) Mult(rgt Exp) ExpBase

Mult builds the * operator (multiplication) for numeric types.

func (ExpBase) Neq

func (b ExpBase) Neq(rgt Exp) Exp

func (ExpBase) NotILike

func (b ExpBase) NotILike(rgt Exp) MatchingBuilder

func (ExpBase) NotIn added in v0.2.0

func (b ExpBase) NotIn(selectOrExpressions SelectOrExpressions) Exp

func (ExpBase) NotLike

func (b ExpBase) NotLike(rgt Exp) MatchingBuilder

func (ExpBase) NotSimilarTo

func (b ExpBase) NotSimilarTo(rgt Exp) MatchingBuilder

func (ExpBase) Op

func (b ExpBase) Op(op Operator, rgt Exp) ExpBase

Op allows to use arbitrary operators.

Example:

N("a").Op(Operator("^"), Int(5))

func (ExpBase) Plus added in v0.2.1

func (b ExpBase) Plus(rgt Exp) ExpBase

Plus builds the + operator (addition) for numeric types.

func (ExpBase) Pow added in v0.2.1

func (b ExpBase) Pow(rgt Exp) ExpBase

Pow builds the ^ operator (exponentiation) for numeric types.

func (ExpBase) RegexpIMatch added in v0.2.5

func (b ExpBase) RegexpIMatch(pattern Exp) Exp

func (ExpBase) RegexpINotMatch added in v0.2.5

func (b ExpBase) RegexpINotMatch(pattern Exp) Exp

func (ExpBase) RegexpMatch added in v0.2.5

func (b ExpBase) RegexpMatch(pattern Exp) Exp

func (ExpBase) RegexpNotMatch added in v0.2.5

func (b ExpBase) RegexpNotMatch(pattern Exp) Exp

func (ExpBase) SimilarTo

func (b ExpBase) SimilarTo(rgt Exp) MatchingBuilder

type Expressions added in v0.4.0

type Expressions []Exp

func Args added in v0.2.0

func Args[T any](arguments ...T) Expressions

Args creates argument expressions for the given arguments.

func (Expressions) IsExp added in v0.4.0

func (e Expressions) IsExp()

func (Expressions) WriteSQL added in v0.4.0

func (e Expressions) WriteSQL(sb *SQLBuilder)

type ForSelectBuilder added in v0.6.0

type ForSelectBuilder struct {
	SelectBuilder
}

func (ForSelectBuilder) Nowait added in v0.6.0

func (fb ForSelectBuilder) Nowait() ForSelectBuilder

func (ForSelectBuilder) Of added in v0.6.0

func (fb ForSelectBuilder) Of(tableName string, tableNames ...string) ForSelectBuilder

func (ForSelectBuilder) SkipLocked added in v0.6.0

func (fb ForSelectBuilder) SkipLocked() ForSelectBuilder

type FromDeleteBuilder added in v0.2.0

type FromDeleteBuilder struct {
	DeleteBuilder
}

func (FromDeleteBuilder) As added in v0.2.0

As sets the alias for the last added from item.

func (FromDeleteBuilder) ColumnAliases added in v0.2.0

func (b FromDeleteBuilder) ColumnAliases(aliases ...string) FromDeleteBuilder

ColumnAliases sets the column aliases for the last added from item.

type FromExp

type FromExp interface {
	SQLWriter // We do not actually use Exp here, since this cannot appear anywhere outside the FROM clause.
	// contains filtered or unexported methods
}

type FromLateralExp

type FromLateralExp interface {
	FromExp
	// contains filtered or unexported methods
}

type FromSelectBuilder

type FromSelectBuilder struct {
	SelectBuilder
}

func (FromSelectBuilder) As

As sets the alias for the last added from item.

func (FromSelectBuilder) ColumnAliases

func (b FromSelectBuilder) ColumnAliases(aliases ...string) FromSelectBuilder

ColumnAliases sets the column aliases for the last added from item.

type FromUpdateBuilder added in v0.2.0

type FromUpdateBuilder struct {
	UpdateBuilder
}

func (FromUpdateBuilder) As added in v0.2.0

As sets the alias for the last added from item.

func (FromUpdateBuilder) ColumnAliases added in v0.2.0

func (b FromUpdateBuilder) ColumnAliases(aliases ...string) FromUpdateBuilder

ColumnAliases sets the column aliases for the last added from item.

type FuncBuilder

type FuncBuilder struct {
	ExpBase
	// contains filtered or unexported fields
}

func Func

func Func(name string, args ...Exp) FuncBuilder

func (FuncBuilder) As

func (b FuncBuilder) As(alias string) FuncBuilder

func (FuncBuilder) ColumnDefinition

func (b FuncBuilder) ColumnDefinition(name, typ string) FuncBuilder

ColumnDefinition adds a column definition to the function call. To add multiple column definitions, call this method multiple times.

func (FuncBuilder) IsExp

func (b FuncBuilder) IsExp()

func (FuncBuilder) NoParensExp added in v0.2.5

func (b FuncBuilder) NoParensExp()

func (FuncBuilder) WithOrdinality

func (b FuncBuilder) WithOrdinality() FuncBuilder

func (FuncBuilder) WriteSQL

func (b FuncBuilder) WriteSQL(sb *SQLBuilder)

type GroupyBySelectBuilder

type GroupyBySelectBuilder struct {
	SelectBuilder
}

func (GroupyBySelectBuilder) Cube

Cube adds a CUBE grouping element for the given expression sets to the GROUP BY clause.

func (GroupyBySelectBuilder) Distinct

Distinct adds the DISTINCT keyword to the GROUP BY clause.

func (GroupyBySelectBuilder) Empty

Empty adds an empty grouping element to the GROUP BY clause.

func (GroupyBySelectBuilder) GroupingSets

func (b GroupyBySelectBuilder) GroupingSets(sets ...[]Exp) GroupyBySelectBuilder

GroupingSets adds a GROUPING SETS grouping element for the given expression sets to the GROUP BY clause.

func (GroupyBySelectBuilder) Rollup

func (b GroupyBySelectBuilder) Rollup(sets ...[]Exp) GroupyBySelectBuilder

Rollup adds a ROLLUP grouping element for the given expression sets to the GROUP BY clause.

type IdentExp

type IdentExp struct {
	ExpBase
	// contains filtered or unexported fields
}

func N

func N(s string) IdentExp

N writes the given name / identifier.

It will validate the identifier when writing the query, but it will not detect all invalid identifiers that are invalid in PostgreSQL (especially considering reserved keywords).

func (IdentExp) Ident added in v0.2.6

func (i IdentExp) Ident() string

func (IdentExp) IsExp

func (i IdentExp) IsExp()

func (IdentExp) NoParensExp added in v0.2.5

func (i IdentExp) NoParensExp()

func (IdentExp) WriteSQL

func (i IdentExp) WriteSQL(sb *SQLBuilder)

type Identer added in v0.3.1

type Identer interface {
	Exp
	Ident() string
	// contains filtered or unexported methods
}

type InsertBuilder

type InsertBuilder struct {
	// contains filtered or unexported fields
}

func InsertInto

func InsertInto(tableName Identer) InsertBuilder

func (InsertBuilder) As

func (b InsertBuilder) As(alias string) InsertBuilder

func (InsertBuilder) ColumnNames

func (b InsertBuilder) ColumnNames(columnName string, rest ...string) InsertBuilder

func (InsertBuilder) DefaultValues added in v0.2.0

func (b InsertBuilder) DefaultValues() InsertBuilder

DefaultValues sets the DEFAULT VALUES clause to insert a row with default values. If InsertBuilder.Values is called after this method, it will overrule the DEFAULT VALUES clause.

func (InsertBuilder) OnConflict added in v0.2.0

func (b InsertBuilder) OnConflict(conflictTargets ...Exp) OnConflictInsertBuilder

OnConflict sets the ON CONFLICT clause with a conflict target expression to the insert. Multiple conflict targets or none can be specified (e.g. for index column names). Specify no conflict target for later addition of ON CONSTRAINT or ON CONFLICT DO NOTHING.

func (InsertBuilder) Query added in v0.2.0

func (b InsertBuilder) Query(query SelectExp) InsertBuilder

Query sets a select query as the values to insert.

func (InsertBuilder) Returning added in v0.2.0

func (b InsertBuilder) Returning(outputExpression Exp) ReturningInsertBuilder

func (InsertBuilder) SetMap

func (b InsertBuilder) SetMap(m map[string]any) InsertBuilder

SetMap sets the column names and values to insert from the given map. It overwrites any previous column names and values.

func (InsertBuilder) Values

func (b InsertBuilder) Values(values ...Exp) InsertBuilder

Values appends the given values to insert. It can be called multiple times to insert multiple rows.

func (InsertBuilder) WriteSQL

func (b InsertBuilder) WriteSQL(sb *SQLBuilder)

WriteSQL writes the insert as an expression.

type JoinSelectBuilder

type JoinSelectBuilder struct {
	SelectBuilder
}

func (JoinSelectBuilder) As

func (JoinSelectBuilder) On

func (b JoinSelectBuilder) On(cond Exp, rest ...Exp) SelectBuilder

func (JoinSelectBuilder) Using

func (b JoinSelectBuilder) Using(columns ...string) SelectBuilder

type JsonBuildObjectBuilder

type JsonBuildObjectBuilder struct {
	// contains filtered or unexported fields
}

func JsonBuildObject

func JsonBuildObject(isJsonB bool) JsonBuildObjectBuilder

func (JsonBuildObjectBuilder) IsExp

func (b JsonBuildObjectBuilder) IsExp()

func (JsonBuildObjectBuilder) NoParensExp added in v0.2.5

func (b JsonBuildObjectBuilder) NoParensExp()

func (JsonBuildObjectBuilder) Prop

func (JsonBuildObjectBuilder) PropIf

func (b JsonBuildObjectBuilder) PropIf(condition bool, key string, value Exp) JsonBuildObjectBuilder

func (JsonBuildObjectBuilder) Start

func (JsonBuildObjectBuilder) Unset

func (JsonBuildObjectBuilder) WriteSQL

func (b JsonBuildObjectBuilder) WriteSQL(sb *SQLBuilder)

type JsonBuildObjectBuilderBuilder

type JsonBuildObjectBuilderBuilder struct {
	// contains filtered or unexported fields
}

func (*JsonBuildObjectBuilderBuilder) End

func (*JsonBuildObjectBuilderBuilder) Prop

func (*JsonBuildObjectBuilderBuilder) PropIf

func (bb *JsonBuildObjectBuilderBuilder) PropIf(condition bool, key string, value Exp) *JsonBuildObjectBuilderBuilder

type MatchingBuilder

type MatchingBuilder interface {
	Exp
	Escape(escapeCharacter rune) MatchingBuilder
}

type OnConflictDoUpdateInsertBuilder added in v0.2.0

type OnConflictDoUpdateInsertBuilder struct {
	InsertBuilder
}

func (OnConflictDoUpdateInsertBuilder) Set added in v0.2.0

Set adds a SET column = value to the DO UPDATE conflict action.

func (OnConflictDoUpdateInsertBuilder) Where added in v0.2.0

Where adds a WHERE condition to the DO UPDATE conflict action. Multiple calls to Where are joined with AND.

type OnConflictInsertBuilder added in v0.2.0

type OnConflictInsertBuilder struct {
	// contains filtered or unexported fields
}

func (OnConflictInsertBuilder) DoNothing added in v0.2.0

func (b OnConflictInsertBuilder) DoNothing() InsertBuilder

func (OnConflictInsertBuilder) DoUpdate added in v0.2.0

func (OnConflictInsertBuilder) OnConstraint added in v0.2.0

func (b OnConflictInsertBuilder) OnConstraint(constraintName string) OnConflictInsertBuilder

func (OnConflictInsertBuilder) Where added in v0.2.0

Where adds a WHERE condition as the index predicate to the conflict target. Multiple calls to Where are joined with AND.

type Operator

type Operator string

type OrderByAggExpBuilder

type OrderByAggExpBuilder struct {
	AggExpBuilder
}

func (OrderByAggExpBuilder) Asc

func (OrderByAggExpBuilder) Desc

func (OrderByAggExpBuilder) NullsFirst

func (OrderByAggExpBuilder) NullsLast

type OrderBySelectBuilder

type OrderBySelectBuilder struct {
	SelectBuilder
}

func (OrderBySelectBuilder) Asc

func (OrderBySelectBuilder) Desc

func (OrderBySelectBuilder) NullsFirst

func (OrderBySelectBuilder) NullsLast

type QueryBuilder

type QueryBuilder struct {
	// contains filtered or unexported fields
}

func Build

func Build(builder SQLWriter) *QueryBuilder

Build starts a new query builder based on the given SQLWriter. For executing the query, use qrbpgx.Build or qrbsql.Build which can set an executor specific to a driver.

func (*QueryBuilder) ToSQL

func (b *QueryBuilder) ToSQL() (sql string, args []any, err error)

func (*QueryBuilder) WithNamedArgs

func (b *QueryBuilder) WithNamedArgs(args map[string]any) *QueryBuilder

func (*QueryBuilder) WithoutValidation

func (b *QueryBuilder) WithoutValidation() *QueryBuilder

WithoutValidation disables validation of the query while building.

Errors might still occur when building the query, but no additional validation (like validating identifiers) will be performed.

type ReturningDeleteBuilder added in v0.2.0

type ReturningDeleteBuilder struct {
	DeleteBuilder
}

func (ReturningDeleteBuilder) As added in v0.2.0

func (b ReturningDeleteBuilder) As(outputName string) DeleteBuilder

As sets the output name for the last output expression.

type ReturningInsertBuilder added in v0.2.0

type ReturningInsertBuilder struct {
	InsertBuilder
}

func (ReturningInsertBuilder) As added in v0.2.0

func (b ReturningInsertBuilder) As(outputName string) InsertBuilder

As sets the output name for the last output expression.

type ReturningUpdateBuilder added in v0.2.0

type ReturningUpdateBuilder struct {
	UpdateBuilder
}

func (ReturningUpdateBuilder) As added in v0.2.0

func (b ReturningUpdateBuilder) As(outputName string) UpdateBuilder

As sets the output name for the last output expression.

type RowsFromBuilder

type RowsFromBuilder struct {
	// contains filtered or unexported fields
}

func NewRowsFromBuilder

func NewRowsFromBuilder(fns ...FuncBuilder) RowsFromBuilder

func (RowsFromBuilder) WithOrdinality

func (r RowsFromBuilder) WithOrdinality() RowsFromBuilder

func (RowsFromBuilder) WriteSQL

func (r RowsFromBuilder) WriteSQL(sb *SQLBuilder)

type SQLBuilder

type SQLBuilder struct {
	// contains filtered or unexported fields
}

func (*SQLBuilder) AddError

func (b *SQLBuilder) AddError(err error)

func (*SQLBuilder) BindPlaceholder

func (b *SQLBuilder) BindPlaceholder(name string) string

func (*SQLBuilder) CreatePlaceholder

func (b *SQLBuilder) CreatePlaceholder(argument any) string

func (*SQLBuilder) Validating

func (b *SQLBuilder) Validating() bool

func (*SQLBuilder) WriteRune

func (b *SQLBuilder) WriteRune(r rune)

func (*SQLBuilder) WriteString

func (b *SQLBuilder) WriteString(s string)

type SQLWriter

type SQLWriter interface {
	WriteSQL(sb *SQLBuilder)
}

type SelectBuilder

type SelectBuilder struct {
	// contains filtered or unexported fields
}

func (SelectBuilder) AppendWith added in v0.2.0

func (b SelectBuilder) AppendWith(w WithBuilder) SelectBuilder

AppendWith adds the given with queries to the select builder.

func (SelectBuilder) ApplyIf

func (b SelectBuilder) ApplyIf(cond bool, apply func(q SelectBuilder) SelectBuilder) SelectBuilder

ApplyIf applies the given function to the builder if the condition is true. It returns the builder itself if the condition is false, otherwise it returns the result of the function. It's especially helpful for building a query conditionally.

func (SelectBuilder) ApplySelectJson added in v0.2.0

ApplySelectJson applies the given function to the current JSON selection (empty JsonBuildObjectBuilder if none set).

func (SelectBuilder) CrossJoin added in v0.3.4

func (b SelectBuilder) CrossJoin(from FromExp) JoinSelectBuilder

func (SelectBuilder) CrossJoinLateral added in v0.3.4

func (b SelectBuilder) CrossJoinLateral(from FromExp) JoinSelectBuilder

func (SelectBuilder) Except

func (b SelectBuilder) Except() CombinationBuilder

func (SelectBuilder) ForKeyShare added in v0.6.0

func (b SelectBuilder) ForKeyShare() ForSelectBuilder

func (SelectBuilder) ForNoKeyUpdate added in v0.6.0

func (b SelectBuilder) ForNoKeyUpdate() ForSelectBuilder

func (SelectBuilder) ForShare added in v0.6.0

func (b SelectBuilder) ForShare() ForSelectBuilder

func (SelectBuilder) ForUpdate added in v0.6.0

func (b SelectBuilder) ForUpdate() ForSelectBuilder

func (SelectBuilder) From

func (SelectBuilder) FromLateral

func (b SelectBuilder) FromLateral(from FromLateralExp) FromSelectBuilder

func (SelectBuilder) FromOnly

func (b SelectBuilder) FromOnly(from FromExp) FromSelectBuilder

func (SelectBuilder) FullJoin

func (b SelectBuilder) FullJoin(from FromExp) JoinSelectBuilder

func (SelectBuilder) GroupBy

func (b SelectBuilder) GroupBy(exps ...Exp) GroupyBySelectBuilder

GroupBy adds a grouping element for the given expressions to the GROUP BY clause. If no expressions are given, special grouping elements can be added via GroupyBySelectBuilder. Use GroupyBySelectBuilder.Empty to add an empty grouping element.

func (SelectBuilder) Having

func (b SelectBuilder) Having(cond Exp) SelectBuilder

Having adds a HAVING condition to the query. Multiple calls to Having are joined with AND.

func (SelectBuilder) Intersect

func (b SelectBuilder) Intersect() CombinationBuilder

func (SelectBuilder) IsExp

func (b SelectBuilder) IsExp()

func (SelectBuilder) Join

func (SelectBuilder) JoinLateral

func (b SelectBuilder) JoinLateral(from FromExp) JoinSelectBuilder

func (SelectBuilder) LeftJoin

func (b SelectBuilder) LeftJoin(from FromExp) JoinSelectBuilder

func (SelectBuilder) LeftJoinLateral

func (b SelectBuilder) LeftJoinLateral(from FromExp) JoinSelectBuilder

func (SelectBuilder) Limit

func (b SelectBuilder) Limit(exp Exp) SelectBuilder

func (SelectBuilder) NoParensExp added in v0.2.5

func (b SelectBuilder) NoParensExp()

func (SelectBuilder) Offset

func (b SelectBuilder) Offset(exp Exp) SelectBuilder

func (SelectBuilder) OrderBy

func (b SelectBuilder) OrderBy(exp Exp) OrderBySelectBuilder

func (SelectBuilder) RightJoin

func (b SelectBuilder) RightJoin(from FromExp) JoinSelectBuilder

func (SelectBuilder) Select

func (b SelectBuilder) Select(exps ...Exp) SelectSelectBuilder

Select adds the given expressions to the select list.

func (SelectBuilder) Union

func (SelectBuilder) Where

func (b SelectBuilder) Where(cond Exp) SelectBuilder

Where adds a WHERE condition to the query. Multiple calls to Where are joined with AND.

func (SelectBuilder) WriteSQL

func (b SelectBuilder) WriteSQL(sb *SQLBuilder)

WriteSQL writes the select as an expression.

type SelectDistinctBuilder

type SelectDistinctBuilder struct {
	SelectBuilder
}

func (SelectDistinctBuilder) On

func (b SelectDistinctBuilder) On(exp Exp, exps ...Exp) SelectBuilder

type SelectExp added in v0.2.0

type SelectExp interface {
	Exp
	// contains filtered or unexported methods
}

type SelectJsonSelectBuilder

type SelectJsonSelectBuilder struct {
	SelectBuilder
}

func (SelectJsonSelectBuilder) As

type SelectOrExpressions added in v0.2.0

type SelectOrExpressions interface {
	Exp
	// contains filtered or unexported methods
}

type SelectSelectBuilder

type SelectSelectBuilder struct {
	SelectBuilder
}

func (SelectSelectBuilder) As

func (SelectSelectBuilder) Distinct

type UpdateBuilder

type UpdateBuilder struct {
	// contains filtered or unexported fields
}

func Update

func Update(tableName Identer) UpdateBuilder

func (UpdateBuilder) As

func (b UpdateBuilder) As(alias string) UpdateBuilder

func (UpdateBuilder) From added in v0.2.0

func (UpdateBuilder) Returning added in v0.2.0

func (b UpdateBuilder) Returning(outputExpression Exp) ReturningUpdateBuilder

func (UpdateBuilder) Set

func (b UpdateBuilder) Set(columnName string, value Exp) UpdateBuilder

func (UpdateBuilder) SetMap

func (b UpdateBuilder) SetMap(m map[string]any) UpdateBuilder

SetMap sets the items in the set clause to the given map. It overwrites any previous set clause items.

func (UpdateBuilder) Where

func (b UpdateBuilder) Where(cond Exp) UpdateBuilder

Where adds a WHERE condition to the update. Multiple calls to Where are joined with AND.

func (UpdateBuilder) WriteSQL

func (b UpdateBuilder) WriteSQL(sb *SQLBuilder)

WriteSQL writes the update as an expression.

type WithBuilder

type WithBuilder struct {
	// contains filtered or unexported fields
}

WithBuilder builds the WITH clause.

func (WithBuilder) DeleteFrom added in v0.2.0

func (b WithBuilder) DeleteFrom(tableName IdentExp) DeleteBuilder

DeleteFrom starts a new DeleteBuilder following the with clause.

func (WithBuilder) InsertInto added in v0.2.0

func (b WithBuilder) InsertInto(tableName IdentExp) InsertBuilder

InsertInto starts a new InsertBuilder following the with clause.

func (WithBuilder) SearchBreadthFirst added in v0.2.0

func (b WithBuilder) SearchBreadthFirst() WithSearchBuilder

func (WithBuilder) SearchDepthFirst added in v0.2.0

func (b WithBuilder) SearchDepthFirst() WithSearchBuilder

func (WithBuilder) Select added in v0.2.0

func (b WithBuilder) Select(exps ...Exp) SelectSelectBuilder

Select starts a new SelectBuilder following the with clause.

func (WithBuilder) Update added in v0.2.0

func (b WithBuilder) Update(tableName IdentExp) UpdateBuilder

Update starts a new UpdateBuilder following the with clause.

func (WithBuilder) With added in v0.2.0

func (b WithBuilder) With(queryName string) WithWithBuilder

With adds a WITH query to the with clause. The actual query must be supplied via As.

func (WithBuilder) WithRecursive added in v0.2.0

func (b WithBuilder) WithRecursive(queryName string) WithWithBuilder

WithRecursive adds a WITH RECURSIVE query to the select builder. The actual query must be supplied via As.

type WithQuery

type WithQuery interface {
	SQLWriter
	// contains filtered or unexported methods
}

type WithSearchBuilder

type WithSearchBuilder struct {
	// contains filtered or unexported fields
}

func (WithSearchBuilder) By

func (b WithSearchBuilder) By(columnName Exp, columnNames ...Exp) WithSearchByBuilder

type WithSearchByBuilder

type WithSearchByBuilder struct {
	// contains filtered or unexported fields
}

func (WithSearchByBuilder) Set

func (b WithSearchByBuilder) Set(searchColumnName string) WithBuilder

type WithWithBuilder added in v0.2.0

type WithWithBuilder struct {
	// contains filtered or unexported fields
}

func With added in v0.2.0

func With(queryName string) WithWithBuilder

With starts a new WITH clause.

func WithRecursive added in v0.2.0

func WithRecursive(queryName string) WithWithBuilder

WithRecursive starts a new WITH RECURSIVE clause.

func (WithWithBuilder) As added in v0.2.0

func (WithWithBuilder) AsMaterialized added in v0.2.0

func (b WithWithBuilder) AsMaterialized(builder WithQuery) WithBuilder

func (WithWithBuilder) AsNotMaterialized added in v0.2.0

func (b WithWithBuilder) AsNotMaterialized(builder WithQuery) WithBuilder

func (WithWithBuilder) ColumnNames added in v0.2.0

func (b WithWithBuilder) ColumnNames(names ...string) WithWithBuilder

ColumnNames sets the column names for the currently started WITH query.

Jump to

Keyboard shortcuts

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