Documentation
¶
Index ¶
- Variables
- type AggExpBuilder
- type CaseBuilder
- type CaseExp
- type CaseWhenBuilder
- type CombinationBuilder
- type DeleteBuilder
- type Exp
- type ExpBase
- func Arg(argument any) ExpBase
- func Bind(argName string) ExpBase
- func Coalesce(exp Exp, rest ...Exp) ExpBase
- func FuncExp(name string, args []Exp) ExpBase
- func Greatest(exp Exp, rest ...Exp) ExpBase
- func Least(exp Exp, rest ...Exp) ExpBase
- func Neg(exp Exp) ExpBase
- func NullIf(value1, value2 Exp) ExpBase
- func (b ExpBase) Cast(typ string) ExpBase
- func (b ExpBase) Concat(rgt Exp) ExpBase
- func (b ExpBase) ContainedBy(rgt Exp) ExpBase
- func (b ExpBase) Contains(rgt Exp) ExpBase
- func (b ExpBase) Divide(rgt Exp) ExpBase
- func (b ExpBase) Eq(rgt Exp) Exp
- func (b ExpBase) Gt(rgt Exp) Exp
- func (b ExpBase) Gte(rgt Exp) Exp
- func (b ExpBase) ILike(rgt Exp) MatchingBuilder
- func (b ExpBase) In(selectOrExpressions SelectOrExpressions) Exp
- func (ExpBase) IsExp()
- func (b ExpBase) IsNotNull() Exp
- func (b ExpBase) IsNull() Exp
- func (b ExpBase) JsonExtract(rgt Exp) ExpBase
- func (b ExpBase) JsonExtractPath(rgt Exp) ExpBase
- func (b ExpBase) JsonExtractPathText(rgt Exp) ExpBase
- func (b ExpBase) JsonExtractText(rgt Exp) ExpBase
- func (b ExpBase) Like(rgt Exp) MatchingBuilder
- func (b ExpBase) Lt(rgt Exp) Exp
- func (b ExpBase) Lte(rgt Exp) Exp
- func (b ExpBase) Minus(rgt Exp) ExpBase
- func (b ExpBase) Mod(rgt Exp) ExpBase
- func (b ExpBase) Mult(rgt Exp) ExpBase
- func (b ExpBase) Neq(rgt Exp) Exp
- func (b ExpBase) NotILike(rgt Exp) MatchingBuilder
- func (b ExpBase) NotIn(selectOrExpressions SelectOrExpressions) Exp
- func (b ExpBase) NotLike(rgt Exp) MatchingBuilder
- func (b ExpBase) NotSimilarTo(rgt Exp) MatchingBuilder
- func (b ExpBase) Op(op Operator, rgt Exp) ExpBase
- func (b ExpBase) Plus(rgt Exp) ExpBase
- func (b ExpBase) Pow(rgt Exp) ExpBase
- func (b ExpBase) RegexpIMatch(pattern Exp) Exp
- func (b ExpBase) RegexpINotMatch(pattern Exp) Exp
- func (b ExpBase) RegexpMatch(pattern Exp) Exp
- func (b ExpBase) RegexpNotMatch(pattern Exp) Exp
- func (b ExpBase) SimilarTo(rgt Exp) MatchingBuilder
- type Expressions
- type ForSelectBuilder
- type FromDeleteBuilder
- type FromExp
- type FromLateralExp
- type FromSelectBuilder
- type FromUpdateBuilder
- type FuncBuilder
- type GroupyBySelectBuilder
- func (b GroupyBySelectBuilder) Cube(sets ...[]Exp) GroupyBySelectBuilder
- func (b GroupyBySelectBuilder) Distinct() GroupyBySelectBuilder
- func (b GroupyBySelectBuilder) Empty() GroupyBySelectBuilder
- func (b GroupyBySelectBuilder) GroupingSets(sets ...[]Exp) GroupyBySelectBuilder
- func (b GroupyBySelectBuilder) Rollup(sets ...[]Exp) GroupyBySelectBuilder
- type IdentExp
- type Identer
- type InsertBuilder
- func (b InsertBuilder) As(alias string) InsertBuilder
- func (b InsertBuilder) ColumnNames(columnName string, rest ...string) InsertBuilder
- func (b InsertBuilder) DefaultValues() InsertBuilder
- func (b InsertBuilder) OnConflict(conflictTargets ...Exp) OnConflictInsertBuilder
- func (b InsertBuilder) Query(query SelectExp) InsertBuilder
- func (b InsertBuilder) Returning(outputExpression Exp) ReturningInsertBuilder
- func (b InsertBuilder) SetMap(m map[string]any) InsertBuilder
- func (b InsertBuilder) Values(values ...Exp) InsertBuilder
- func (b InsertBuilder) WriteSQL(sb *SQLBuilder)
- type JoinSelectBuilder
- type JsonBuildObjectBuilder
- func (b JsonBuildObjectBuilder) IsExp()
- func (b JsonBuildObjectBuilder) NoParensExp()
- func (b JsonBuildObjectBuilder) Prop(key string, value Exp) JsonBuildObjectBuilder
- func (b JsonBuildObjectBuilder) PropIf(condition bool, key string, value Exp) JsonBuildObjectBuilder
- func (b JsonBuildObjectBuilder) Start() *JsonBuildObjectBuilderBuilder
- func (b JsonBuildObjectBuilder) Unset(key string) JsonBuildObjectBuilder
- func (b JsonBuildObjectBuilder) WriteSQL(sb *SQLBuilder)
- type JsonBuildObjectBuilderBuilder
- type MatchingBuilder
- type OnConflictDoUpdateInsertBuilder
- type OnConflictInsertBuilder
- func (b OnConflictInsertBuilder) DoNothing() InsertBuilder
- func (b OnConflictInsertBuilder) DoUpdate() OnConflictDoUpdateInsertBuilder
- func (b OnConflictInsertBuilder) OnConstraint(constraintName string) OnConflictInsertBuilder
- func (b OnConflictInsertBuilder) Where(cond Exp) OnConflictInsertBuilder
- type Operator
- type OrderByAggExpBuilder
- type OrderBySelectBuilder
- type QueryBuilder
- type ReturningDeleteBuilder
- type ReturningInsertBuilder
- type ReturningUpdateBuilder
- type RowsFromBuilder
- type SQLBuilder
- type SQLWriter
- type SelectBuilder
- func (b SelectBuilder) AppendWith(w WithBuilder) SelectBuilder
- func (b SelectBuilder) ApplyIf(cond bool, apply func(q SelectBuilder) SelectBuilder) SelectBuilder
- func (b SelectBuilder) ApplySelectJson(apply func(obj JsonBuildObjectBuilder) JsonBuildObjectBuilder) SelectJsonSelectBuilder
- func (b SelectBuilder) CrossJoin(from FromExp) JoinSelectBuilder
- func (b SelectBuilder) CrossJoinLateral(from FromExp) JoinSelectBuilder
- func (b SelectBuilder) Except() CombinationBuilder
- func (b SelectBuilder) ForKeyShare() ForSelectBuilder
- func (b SelectBuilder) ForNoKeyUpdate() ForSelectBuilder
- func (b SelectBuilder) ForShare() ForSelectBuilder
- func (b SelectBuilder) ForUpdate() ForSelectBuilder
- func (b SelectBuilder) From(from FromExp) FromSelectBuilder
- func (b SelectBuilder) FromLateral(from FromLateralExp) FromSelectBuilder
- func (b SelectBuilder) FromOnly(from FromExp) FromSelectBuilder
- func (b SelectBuilder) FullJoin(from FromExp) JoinSelectBuilder
- func (b SelectBuilder) GroupBy(exps ...Exp) GroupyBySelectBuilder
- func (b SelectBuilder) Having(cond Exp) SelectBuilder
- func (b SelectBuilder) Intersect() CombinationBuilder
- func (b SelectBuilder) IsExp()
- func (b SelectBuilder) Join(from FromExp) JoinSelectBuilder
- func (b SelectBuilder) JoinLateral(from FromExp) JoinSelectBuilder
- func (b SelectBuilder) LeftJoin(from FromExp) JoinSelectBuilder
- func (b SelectBuilder) LeftJoinLateral(from FromExp) JoinSelectBuilder
- func (b SelectBuilder) Limit(exp Exp) SelectBuilder
- func (b SelectBuilder) NoParensExp()
- func (b SelectBuilder) Offset(exp Exp) SelectBuilder
- func (b SelectBuilder) OrderBy(exp Exp) OrderBySelectBuilder
- func (b SelectBuilder) RightJoin(from FromExp) JoinSelectBuilder
- func (b SelectBuilder) Select(exps ...Exp) SelectSelectBuilder
- func (b SelectBuilder) Union() CombinationBuilder
- func (b SelectBuilder) Where(cond Exp) SelectBuilder
- func (b SelectBuilder) WriteSQL(sb *SQLBuilder)
- type SelectDistinctBuilder
- type SelectExp
- type SelectJsonSelectBuilder
- type SelectOrExpressions
- type SelectSelectBuilder
- type UpdateBuilder
- func (b UpdateBuilder) As(alias string) UpdateBuilder
- func (b UpdateBuilder) From(from FromExp) FromUpdateBuilder
- func (b UpdateBuilder) Returning(outputExpression Exp) ReturningUpdateBuilder
- func (b UpdateBuilder) Set(columnName string, value Exp) UpdateBuilder
- func (b UpdateBuilder) SetMap(m map[string]any) UpdateBuilder
- func (b UpdateBuilder) Where(cond Exp) UpdateBuilder
- func (b UpdateBuilder) WriteSQL(sb *SQLBuilder)
- type WithBuilder
- func (b WithBuilder) DeleteFrom(tableName IdentExp) DeleteBuilder
- func (b WithBuilder) InsertInto(tableName IdentExp) InsertBuilder
- func (b WithBuilder) SearchBreadthFirst() WithSearchBuilder
- func (b WithBuilder) SearchDepthFirst() WithSearchBuilder
- func (b WithBuilder) Select(exps ...Exp) SelectSelectBuilder
- func (b WithBuilder) Update(tableName IdentExp) UpdateBuilder
- func (b WithBuilder) With(queryName string) WithWithBuilder
- func (b WithBuilder) WithRecursive(queryName string) WithWithBuilder
- type WithQuery
- type WithSearchBuilder
- type WithSearchByBuilder
- type WithWithBuilder
Constants ¶
This section is empty.
Variables ¶
var ErrFromItemLateralAndOnly = errors.New("from item: cannot specify both LATERAL and ONLY")
var ErrInsertConflictConstraintAndTarget = errors.New("insert: cannot set both conflict constraint name and targets")
var ErrInsertValuesAndQuery = errors.New("insert: cannot set both values and query")
var ErrInvalidIdentifier = errors.New("identifier: invalid")
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 ¶
func (b CombinationBuilder) All() CombinationBuilder
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 }
type ExpBase ¶
type ExpBase struct {
Exp
}
ExpBase is a base type for expressions to allow embedding of various default operators.
func Arg ¶
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 ¶
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 (ExpBase) ContainedBy ¶ added in v0.2.4
func (ExpBase) Divide ¶ added in v0.2.1
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) 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) JsonExtract ¶
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 ¶
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 ¶
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 ¶
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) Mult ¶ added in v0.2.1
Mult builds the * operator (multiplication) for numeric types.
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) RegexpIMatch ¶ added in v0.2.5
func (ExpBase) RegexpINotMatch ¶ added in v0.2.5
func (ExpBase) RegexpMatch ¶ added in v0.2.5
func (ExpBase) RegexpNotMatch ¶ added in v0.2.5
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
func (b FromDeleteBuilder) As(alias string) FromDeleteBuilder
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 ¶
func (b FromSelectBuilder) As(alias string) FromSelectBuilder
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
func (b FromUpdateBuilder) As(alias string) FromUpdateBuilder
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 ¶
func (b GroupyBySelectBuilder) Cube(sets ...[]Exp) GroupyBySelectBuilder
Cube adds a CUBE grouping element for the given expression sets to the GROUP BY clause.
func (GroupyBySelectBuilder) Distinct ¶
func (b GroupyBySelectBuilder) Distinct() GroupyBySelectBuilder
Distinct adds the DISTINCT keyword to the GROUP BY clause.
func (GroupyBySelectBuilder) Empty ¶
func (b GroupyBySelectBuilder) Empty() GroupyBySelectBuilder
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 ¶
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) NoParensExp ¶ added in v0.2.5
func (i IdentExp) NoParensExp()
func (IdentExp) WriteSQL ¶
func (i IdentExp) WriteSQL(sb *SQLBuilder)
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 (b JoinSelectBuilder) As(alias string) JoinSelectBuilder
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 (b JsonBuildObjectBuilder) Prop(key string, value Exp) JsonBuildObjectBuilder
func (JsonBuildObjectBuilder) PropIf ¶
func (b JsonBuildObjectBuilder) PropIf(condition bool, key string, value Exp) JsonBuildObjectBuilder
func (JsonBuildObjectBuilder) Start ¶
func (b JsonBuildObjectBuilder) Start() *JsonBuildObjectBuilderBuilder
func (JsonBuildObjectBuilder) Unset ¶
func (b JsonBuildObjectBuilder) Unset(key string) JsonBuildObjectBuilder
func (JsonBuildObjectBuilder) WriteSQL ¶
func (b JsonBuildObjectBuilder) WriteSQL(sb *SQLBuilder)
type JsonBuildObjectBuilderBuilder ¶
type JsonBuildObjectBuilderBuilder struct {
// contains filtered or unexported fields
}
func (*JsonBuildObjectBuilderBuilder) End ¶
func (bb *JsonBuildObjectBuilderBuilder) End() JsonBuildObjectBuilder
func (*JsonBuildObjectBuilderBuilder) Prop ¶
func (bb *JsonBuildObjectBuilderBuilder) Prop(key string, value Exp) *JsonBuildObjectBuilderBuilder
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
func (b OnConflictDoUpdateInsertBuilder) Set(columnName string, value Exp) OnConflictDoUpdateInsertBuilder
Set adds a SET column = value to the DO UPDATE conflict action.
func (OnConflictDoUpdateInsertBuilder) Where ¶ added in v0.2.0
func (b OnConflictDoUpdateInsertBuilder) Where(cond Exp) OnConflictDoUpdateInsertBuilder
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 (b OnConflictInsertBuilder) DoUpdate() OnConflictDoUpdateInsertBuilder
func (OnConflictInsertBuilder) OnConstraint ¶ added in v0.2.0
func (b OnConflictInsertBuilder) OnConstraint(constraintName string) OnConflictInsertBuilder
func (OnConflictInsertBuilder) Where ¶ added in v0.2.0
func (b OnConflictInsertBuilder) Where(cond Exp) OnConflictInsertBuilder
Where adds a WHERE condition as the index predicate to the conflict target. Multiple calls to Where are joined with AND.
type OrderByAggExpBuilder ¶
type OrderByAggExpBuilder struct {
AggExpBuilder
}
func (OrderByAggExpBuilder) Asc ¶
func (b OrderByAggExpBuilder) Asc() OrderByAggExpBuilder
func (OrderByAggExpBuilder) Desc ¶
func (b OrderByAggExpBuilder) Desc() OrderByAggExpBuilder
func (OrderByAggExpBuilder) NullsFirst ¶
func (b OrderByAggExpBuilder) NullsFirst() OrderByAggExpBuilder
func (OrderByAggExpBuilder) NullsLast ¶
func (b OrderByAggExpBuilder) NullsLast() OrderByAggExpBuilder
type OrderBySelectBuilder ¶
type OrderBySelectBuilder struct {
SelectBuilder
}
func (OrderBySelectBuilder) Asc ¶
func (b OrderBySelectBuilder) Asc() OrderBySelectBuilder
func (OrderBySelectBuilder) Desc ¶
func (b OrderBySelectBuilder) Desc() OrderBySelectBuilder
func (OrderBySelectBuilder) NullsFirst ¶
func (b OrderBySelectBuilder) NullsFirst() OrderBySelectBuilder
func (OrderBySelectBuilder) NullsLast ¶
func (b OrderBySelectBuilder) NullsLast() OrderBySelectBuilder
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) 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
func (b SelectBuilder) ApplySelectJson(apply func(obj JsonBuildObjectBuilder) JsonBuildObjectBuilder) SelectJsonSelectBuilder
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 (b SelectBuilder) From(from FromExp) FromSelectBuilder
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 (b SelectBuilder) Join(from FromExp) JoinSelectBuilder
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 (b SelectBuilder) Union() CombinationBuilder
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 ¶
func (b SelectJsonSelectBuilder) As(alias string) SelectJsonSelectBuilder
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 (b SelectSelectBuilder) As(alias string) SelectSelectBuilder
func (SelectSelectBuilder) Distinct ¶
func (b SelectSelectBuilder) Distinct() SelectDistinctBuilder
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 (b UpdateBuilder) From(from FromExp) FromUpdateBuilder
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 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 (b WithWithBuilder) As(query WithQuery) WithBuilder
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.
Source Files
¶
- agg_exp.go
- args.go
- delete_builder.go
- exp.go
- func_builder.go
- functions.go
- functions_conditional.go
- functions_matching.go
- helper.go
- ident.go
- immutable_map.go
- immutable_slice_map.go
- insert_builder.go
- json_build_object.go
- literals.go
- op.go
- op_json.go
- op_math.go
- order_by.go
- query_builder.go
- select_builder.go
- sql_writer.go
- update_builder.go
- with_builder.go