chain

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// NullValue represents the NULL value in SQL
	NullValue = "NULL"
	// CurrentTimestampPGFn is the name of the function of postgres that returns current
	// timestamp with tz.
	CurrentTimestampPGFn = "CURRENT_TIMESTAMP"
)
View Source
const (
	// SQLNothing is the default value for an SQLBool
	SQLNothing sqlBool = ""
	// SQLAnd represents AND in SQL
	SQLAnd sqlBool = "AND"
	// SQLOr represents OR in SQL
	SQLOr sqlBool = "OR"
	// SQLNot represents NOT in SQL
	SQLNot sqlBool = "NOT"
	// SQLAndNot Negates the expression after AND
	SQLAndNot sqlBool = "AND NOT"
	// SQLOrNot Neates the expression after OR
	SQLOrNot sqlBool = "OR NOT"
)
View Source
const (
	// SQLAll is a modifier that can be append to UNION, INTERSECT and EXCEPT
	SQLAll sqlModifier = "ALL"
	// SQLForUpdate is a modifier that can be append to select to lock a row to a given transaction.
	SQLForUpdate sqlModifier = "FOR UPDATE"
)

Variables

This section is empty.

Functions

func AVG added in v0.1.16

func AVG(column string) string

AVG Renders SQL AVG of the expression in column

func AndConditions added in v0.1.16

func AndConditions(conditions ...string) string

AndConditions returns a list of conditions separated by AND

func As

func As(field, alias string) string

As is a convenience function to define column alias in go in order to be a bit less error prone and more go semantic.

func COUNT added in v0.1.16

func COUNT(column string) string

COUNT Renders SQL COUNT of the expression in column

func ColumnGroup added in v0.1.16

func ColumnGroup(columns ...string) string

ColumnGroup returns a list of columns, comma separated and between parenthesis.

func CompareExpressions added in v1.0.0

func CompareExpressions(operator CompOperator, columnLeft, columnRight string) string

CompareExpressions returns a comparison between two SQL expressions using operator

func Constraint

func Constraint(constraint string) string

Constraint wraps the passed constraint name with the required SQL to use it.

func Distinct added in v0.1.16

func Distinct(field string) string

Distinct allows selection of distinct results only.

func Equals

func Equals(field string) string

Equals is a convenience function to enable use of go for where definitions

func ExpandArgs added in v1.0.0

func ExpandArgs(args []interface{}, querySegment string) (string, []interface{})

ExpandArgs will unravel a slice of arguments, converting slices into individual items to determine if an item needs unraveling it uses the placeholders (? marks) for the future positional arguments in a query segment.

func GreaterOrEqualThan

func GreaterOrEqualThan(field string) string

GreaterOrEqualThan is a convenience function to enable use of go for where definitions

func GreaterThan

func GreaterThan(field string) string

GreaterThan is a convenience function to enable use of go for where definitions

func In

func In(field string, value ...interface{}) (string, []interface{})

In is a convenience function to enable use of go for where definitions

func InSlice added in v0.1.16

func InSlice(field string, value interface{}) (string, interface{})

InSlice is a convenience function to enable use of go for where definitions and assumes the passed value is already a slice.

func IsNoRows added in v0.1.16

func IsNoRows(err error) bool

IsNoRows returns true if the passed error is one of the many possibilities of no rows returned by the different libraries.

func LesserOrEqualThan

func LesserOrEqualThan(field string) string

LesserOrEqualThan is a convenience function to enable use of go for where definitions

func LesserThan

func LesserThan(field string) string

LesserThan is a convenience function to enable use of go for where definitions

func Like added in v0.1.16

func Like(field string) string

Like is a convenience function to enable use of go for where definitions

func MAX added in v0.1.16

func MAX(column string) string

MAX Renders SQL MAX of the expression in column

func MIN added in v0.1.16

func MIN(column string) string

MIN Renders SQL MIN of the expression in column

func MarksToPlaceholders added in v0.1.16

func MarksToPlaceholders(q string, args []interface{}) (string, []interface{}, error)

MarksToPlaceholders replaces `?` in the query with `$1` style placeholders, this must be done with a finished query and requires the args as they depend on the position of the already rendered query, it does some consistency control and finally expands `(?)`.

func NillableInt64 added in v0.1.16

func NillableInt64(i *int64) int64

NillableInt64 returns a safely dereferenced int64 from it's pointer.

func NillableString added in v0.1.16

func NillableString(s *string) string

NillableString returns a safely dereferenced string from it's pointer.

func NotEquals

func NotEquals(field string) string

NotEquals is a convenience function to enable use of go for where definitions

func NotLike added in v0.1.16

func NotLike(field string) string

NotLike is a convenience function to enable use of go for where definitions

func NotNull added in v0.1.2

func NotNull(field string) string

NotNull is a convenience function to enable use of go for where definitions

func Null added in v0.1.2

func Null(field string) string

Null is a convenience function to enable use of go for where definitions

func OrConditions added in v1.1.0

func OrConditions(conditions ...string) string

OrConditions returns a list of conditions separated by OR

func PlaceholdersToPositional added in v1.0.0

func PlaceholdersToPositional(q *strings.Builder, argCount int) (*strings.Builder, int, error)

PlaceholdersToPositional converts ? in a query into $<argument number> which postgres expects

func SUM added in v0.1.16

func SUM(column string) string

SUM Renders SQL SUM of the expression in column

func SetToCurrentTimestamp added in v0.1.7

func SetToCurrentTimestamp(field string) string

SetToCurrentTimestamp crafts a postgres SQL assignment of the field to the current timestamp with timezone.

func SimpleFunction added in v0.1.16

func SimpleFunction(fName, params string) string

SimpleFunction returns the rendered fName invocation passing params as argument

func TablePrefix added in v0.1.16

func TablePrefix(n string) func(string) string

TablePrefix returns a function that prefixes column names with the passed table name.

Types

type CompOperator added in v0.1.16

type CompOperator string

CompOperator represents a possible operator to compare two SQL expressions

var (
	// Eq is the = operand
	Eq CompOperator = "="
	// Neq is the != operand
	Neq CompOperator = "!="
	// Gt is the > operand
	Gt CompOperator = ">"
	// GtE is the >= operand
	GtE CompOperator = ">="
	// Lt is the < operand
	Lt CompOperator = "<"
	// LtE is the <= operand
	LtE CompOperator = "<="
	// Lk is the LIKE operand
	Lk CompOperator = "LIKE"
	// NLk is the NOT LIKE operand
	NLk CompOperator = "NOT LIKE"
)

type ExpressionChain added in v1.0.0

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

ExpressionChain holds all the atoms for the SQL expressions that make a query and allows to chain more assuming the chaining is valid.

func New added in v1.0.0

func New(db connection.DB) *ExpressionChain

New returns a new instance of ExpressionChain hooked to the passed DB

func NewExpressionChain added in v1.0.0

func NewExpressionChain(db connection.DB) *ExpressionChain

NewExpressionChain returns a new instance of ExpressionChain hooked to the passed DB Deprecated: please use New instead

func NewNoDB added in v1.0.0

func NewNoDB() *ExpressionChain

NewNoDB creates an expression chain withouth the db, mostly with the purpose of making a more abbreviated syntax for transient ExpresionChains such as CTE or subquery ones.

func (*ExpressionChain) AddUnionFromChain added in v1.0.0

func (ec *ExpressionChain) AddUnionFromChain(union *ExpressionChain, all bool) (*ExpressionChain, error)

AddUnionFromChain renders the passed chain and adds it to the current one as a Union returned ExpressionChain pointer is of current chain modified.

func (*ExpressionChain) AndHaving added in v1.0.0

func (ec *ExpressionChain) AndHaving(expr string, args ...interface{}) *ExpressionChain

AndHaving adds a 'HAVING' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) AndWhere added in v1.0.0

func (ec *ExpressionChain) AndWhere(expr string, args ...interface{}) *ExpressionChain

AndWhere adds a 'AND WHERE' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) AndWhereGroup added in v1.0.0

func (ec *ExpressionChain) AndWhereGroup(c *ExpressionChain) *ExpressionChain

AndWhereGroup adds an AND ( a = b AND/OR c = d...) basically a group of conditions preceded by AND unless it's the first condition then just the group. It takes an expression chain as a parameter which does not need an DB or any other expression other than WHEREs `NewNoDB().AndWhere(...).OrWhere(...)` THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) Clone added in v1.0.0

func (ec *ExpressionChain) Clone() *ExpressionChain

Clone returns a copy of the ExpressionChain

func (*ExpressionChain) DB added in v1.0.0

func (ec *ExpressionChain) DB() connection.DB

DB returns the chain DB

func (*ExpressionChain) Delete added in v1.0.0

func (ec *ExpressionChain) Delete() *ExpressionChain

Delete determines a deletion will be made with the results of the query.

func (*ExpressionChain) Exec added in v1.0.0

func (ec *ExpressionChain) Exec(ctx context.Context) (execError error)

Exec executes the chain, works for Insert and Update

func (*ExpressionChain) ExecResult added in v1.0.0

func (ec *ExpressionChain) ExecResult(ctx context.Context) (rowsAffected int64, execError error)

ExecResult executes the chain and returns rows affected info, works for Insert and Update

func (*ExpressionChain) Fetch added in v1.0.0

func (ec *ExpressionChain) Fetch(ctx context.Context, receiver interface{}) error

Fetch is a one step version of the Query->fetch typical workflow.

func (*ExpressionChain) FetchIntoPrimitive added in v1.0.0

func (ec *ExpressionChain) FetchIntoPrimitive(ctx context.Context, receiver interface{}) error

FetchIntoPrimitive is a one step version of the QueryPrimitive->fetch typical workflow.

func (*ExpressionChain) ForUpdate added in v1.0.8

func (ec *ExpressionChain) ForUpdate() *ExpressionChain

ForUpdate appends `FOR UPDATE` to a SQL SELECT

func (*ExpressionChain) From added in v1.0.0

func (ec *ExpressionChain) From(table string) *ExpressionChain

From sets the table to be used in the `FROM` expression. Functionally this is identical to `Table()`, but it makes code more readable in some circumstances. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) FromUpdate added in v1.0.3

func (ec *ExpressionChain) FromUpdate(expr string, args ...interface{}) *ExpressionChain

FromUpdate adds a special case of from, for UPDATE where FROM is used as JOIN

func (*ExpressionChain) FullJoin added in v1.0.0

func (ec *ExpressionChain) FullJoin(expr, on string, args ...interface{}) *ExpressionChain

FullJoin adds a 'FULL JOIN' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) GroupBy added in v1.0.0

func (ec *ExpressionChain) GroupBy(expr string, args ...interface{}) *ExpressionChain

GroupBy adds a 'GROUP BY' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) GroupByReplace added in v1.0.0

func (ec *ExpressionChain) GroupByReplace(expr string, args ...interface{}) *ExpressionChain

GroupByReplace adds a 'GROUP BY' to the 'ExpressionChain' and returns the same chain to facilitate further chaining, this version of group by removes all other group by entries. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) InnerJoin added in v1.0.0

func (ec *ExpressionChain) InnerJoin(expr, on string, args ...interface{}) *ExpressionChain

InnerJoin adds a 'INNER JOIN' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) Insert added in v1.0.0

func (ec *ExpressionChain) Insert(insertPairs map[string]interface{}) *ExpressionChain

Insert set fields/values for insertion.

func (*ExpressionChain) InsertMulti added in v1.0.0

func (ec *ExpressionChain) InsertMulti(insertPairs map[string][]interface{}) (*ExpressionChain, error)

InsertMulti set fields/values for insertion.

func (*ExpressionChain) Join added in v1.0.0

func (ec *ExpressionChain) Join(expr, on string, args ...interface{}) *ExpressionChain

Join adds a 'JOIN' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) LeftJoin added in v1.0.0

func (ec *ExpressionChain) LeftJoin(expr, on string, args ...interface{}) *ExpressionChain

LeftJoin adds a 'LEFT JOIN' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) Limit added in v1.0.0

func (ec *ExpressionChain) Limit(limit int64) *ExpressionChain

Limit adds a 'LIMIT' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) NewDB added in v1.0.0

NewDB sets the passed db as this chain's db.

func (*ExpressionChain) Offset added in v1.0.0

func (ec *ExpressionChain) Offset(offset int64) *ExpressionChain

Offset adds a 'OFFSET' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) OnConflict added in v1.0.0

func (ec *ExpressionChain) OnConflict(clause func(*OnConflict)) *ExpressionChain

OnConflict will add a "ON CONFLICT" clause at the end of the query if the main operation is an INSERT.

func (*ExpressionChain) OrHaving added in v1.0.0

func (ec *ExpressionChain) OrHaving(expr string, args ...interface{}) *ExpressionChain

OrHaving adds a 'HAVING' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) OrWhere added in v1.0.0

func (ec *ExpressionChain) OrWhere(expr string, args ...interface{}) *ExpressionChain

OrWhere adds a 'OR WHERE' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) OrWhereGroup added in v1.0.0

func (ec *ExpressionChain) OrWhereGroup(c *ExpressionChain) *ExpressionChain

OrWhereGroup adds an OR ( a = b AND/OR c = d...) basically a group of conditions preceded by OR unless it's the first condition and there are no ANDs present. It takes an expression chain as a parameter which does not need an DB or any other expression other than WHEREs `NewNoDB().AndWhere(...).OrWhere(...)` THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) OrderBy added in v1.0.0

func (ec *ExpressionChain) OrderBy(order *OrderByOperator) *ExpressionChain

OrderBy adds a 'ORDER BY' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) Query added in v1.0.0

Query is a convenience function to run the current chain through the db query with iterator.

func (*ExpressionChain) QueryIter added in v1.0.0

QueryIter is a convenience function to run the current chain through the db query with iterator.

func (*ExpressionChain) QueryPrimitive added in v1.0.0

func (ec *ExpressionChain) QueryPrimitive(ctx context.Context) (connection.ResultFetch, error)

QueryPrimitive is a convenience function to run the current chain through the db query.

func (*ExpressionChain) Raw added in v1.0.0

func (ec *ExpressionChain) Raw(ctx context.Context, fields ...interface{}) error

Raw executes the query and tries to scan the result into fields without much safeguard nor intelligence so you will have to put some of your own

func (*ExpressionChain) Render added in v1.0.0

func (ec *ExpressionChain) Render() (string, []interface{}, error)

Render returns the SQL expression string and the arguments of said expression, there is no checkig of validity or consistency for the time being.

func (*ExpressionChain) RenderRaw added in v1.0.0

func (ec *ExpressionChain) RenderRaw() (string, []interface{}, error)

RenderRaw returns the SQL expression string and the arguments of said expression, No positional argument replacement is done.

func (*ExpressionChain) Returning added in v1.0.0

func (ec *ExpressionChain) Returning(args ...string) *ExpressionChain

Returning will add an "RETURNING" clause at the end of the query if the main operation is an INSERT.

Please note that `Returning` likely doesn't do what you expect. There are systemic issues with dependencies and `go-lang` standard library that prevent it from operating correctly in many scenarios.

func (*ExpressionChain) RightJoin added in v1.0.0

func (ec *ExpressionChain) RightJoin(expr, on string, args ...interface{}) *ExpressionChain

RightJoin adds a 'RIGHT JOIN' to the 'ExpressionChain' and returns the same chan to facilitate further chaining. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) Select added in v1.0.0

func (ec *ExpressionChain) Select(fields ...string) *ExpressionChain

Select set fields to be returned by the final query.

func (*ExpressionChain) SelectWithArgs added in v1.0.0

func (ec *ExpressionChain) SelectWithArgs(fields ...SelectArgument) *ExpressionChain

SelectWithArgs set fields to be returned by the final query.

func (*ExpressionChain) Set added in v1.0.0

func (ec *ExpressionChain) Set(set string) *ExpressionChain

Set will produce your chain to be run inside a Transaction and used for `SET LOCAL` For the moment this is only used with Exec.

func (*ExpressionChain) SetMinQuerySize added in v1.0.0

func (ec *ExpressionChain) SetMinQuerySize(size uint64)

SetMinQuerySize will make sure that at least <size> bytes (runes actually) are allocated before rendering to avoid costly resize and copy operations while rendering, use only if you know what you are doing, 0 uses go allocator.

func (*ExpressionChain) String added in v1.0.0

func (ec *ExpressionChain) String() string

String implements the stringer interface. It is intended to be used for logging/debugging purposes only.

func (*ExpressionChain) Table added in v1.0.0

func (ec *ExpressionChain) Table(table string) *ExpressionChain

Table sets the table to be used in the 'FROM' expression. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

func (*ExpressionChain) TablePrefixes added in v1.0.0

func (ec *ExpressionChain) TablePrefixes() *Formatter

TablePrefixes returns the formatter for this expression, if none exists one will be created

func (*ExpressionChain) Union added in v1.0.0

func (ec *ExpressionChain) Union(unionExpr string, all bool, args ...interface{}) *ExpressionChain

Union adds the passed SQL expression and args as a union to be made on this expression, the change is in place, there are no checks about correctness of the query.

func (*ExpressionChain) Update added in v1.0.0

func (ec *ExpressionChain) Update(expr string, args ...interface{}) *ExpressionChain

Update set fields/values for updates. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

NOTE: values of `nil` will be treated as `NULL`

func (*ExpressionChain) UpdateMap added in v1.0.0

func (ec *ExpressionChain) UpdateMap(exprMap map[string]interface{}) *ExpressionChain

UpdateMap set fields/values for updates but does so from a map of key/value. THIS DOES NOT CREATE A COPY OF THE CHAIN, IT MUTATES IN PLACE.

NOTE: values of `nil` will be treated as `NULL`

func (*ExpressionChain) With added in v1.0.0

func (ec *ExpressionChain) With(name string, cte *ExpressionChain) *ExpressionChain

With adds a CTE to your query (https://www.postgresql.org/docs/11/queries-with.html)

type Formatter added in v1.0.0

type Formatter struct {
	FormatTable map[string]string
}

Formatter holds a set of key/values for replacements in queries generated by gaum, this is designed around tablename aliases.

func (*Formatter) Add added in v1.0.0

func (f *Formatter) Add(key, prefix string) bool

Add adds the passed in prefix to the the Formatting table, returns "replaced"

func (*Formatter) Del added in v1.0.0

func (f *Formatter) Del(key string)

Del removes the passed key, if exists, from the formatting table.

func (*Formatter) List added in v1.0.0

func (f *Formatter) List() []string

List returns a list of the keys for table prefixes.

type Function added in v0.1.16

type Function interface {
	// Static adds an argument to the function
	Static(string) Function
	// Parametric adds a placeholder and an argument to the function
	Parametric(interface{}) Function
	// Fn returns the rendered statement and list of arguments.
	Fn() (string, []interface{})
	// FnSelect returns a SelectArgument from this function
	FnSelect() SelectArgument
}

Function represents a SQL function.

func ComplexFunction added in v0.1.16

func ComplexFunction(name string) Function

ComplexFunction constructs a complexFunction

type Group

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

Group allows to group a set of expressions and run them together in a transaction.

func (*Group) Add

func (cg *Group) Add(ec *ExpressionChain)

Add appends a chain to the group.

func (*Group) Run

func (cg *Group) Run(ctx context.Context) (execError error)

Run runs all the chains in a group in a transaction, for this the db of the first query will be used.

func (*Group) Set

func (cg *Group) Set(set string)

Set will cause `SET LOCAL` to be run with this value before executing items of the group in Run.

type OnConflict added in v0.1.16

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

OnConflict is chained to build `OnConflict` statements

func (*OnConflict) DoNothing added in v0.1.16

func (o *OnConflict) DoNothing()

DoNothing terminates the `ON CONFLICT` chain the conflict target is optional for this action.

func (*OnConflict) OnColumn added in v0.1.16

func (o *OnConflict) OnColumn(args ...string) *OnConflictAction

OnColumn is used to construct `ON CONFLICT ( arg0, arg1, arg2 )`. This allows for build things like `ON COLUMN ( myindex, COLLATE my_other_index )`

func (*OnConflict) OnConstraint added in v0.1.16

func (o *OnConflict) OnConstraint(arg string) *OnConflictAction

OnConstraint is used to create an `On CONFLICT ON CONSTRAINT $arg` statement

type OnConflictAction added in v0.1.16

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

OnConflictAction is used to limit developer actions

func (*OnConflictAction) DoNothing added in v0.1.16

func (o *OnConflictAction) DoNothing()

DoNothing terminates the `ON CONFLICT` chain

func (*OnConflictAction) DoUpdate added in v0.1.16

func (o *OnConflictAction) DoUpdate() *OnUpdate

DoUpdate continues the `ON CONFLICT` chain

type OnUpdate added in v0.1.16

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

OnUpdate is used to limit developer actions

func (*OnUpdate) Set added in v0.1.16

func (o *OnUpdate) Set(args ...interface{}) *OnUpdate

Set Sets a field to a value

func (*OnUpdate) SetDefault added in v0.1.16

func (o *OnUpdate) SetDefault(column string) *OnUpdate

SetDefault sets a field to a default value. This is useful to build `ON CONFLICT ON CONSTRAINT my_constraint DO UPDATE SET field = DEFAULT`.

func (*OnUpdate) SetNow added in v0.1.16

func (o *OnUpdate) SetNow(column string) *OnUpdate

SetNow is incrediably useful to set `now()` values. For example: `ON CONFLICT ON CONSTRAINT my_constraint DO UPDATE SET time_value = now()`.

func (*OnUpdate) SetSQL added in v0.1.16

func (o *OnUpdate) SetSQL(args ...string) *OnUpdate

SetSQL Sets a field to a value that needs no escaping, it is assumed to be SQL valid (an expression or column) and inserts parentheses around both keys and values

func (*OnUpdate) SetSQLNoParens added in v1.1.0

func (o *OnUpdate) SetSQLNoParens(args ...string) *OnUpdate

SetSQLNoParens Sets a field to a value that needs no escaping, it is assumed to be SQL valid (an expression or column) and doesn't insert any parentheses around either keys or values

func (*OnUpdate) SetSQLRow added in v1.0.10

func (o *OnUpdate) SetSQLRow(args ...string) *OnUpdate

SetSQLRow Sets a field to a value that needs no escaping, it is assumed to be SQL valid (an expression or column) it will append ROW to the values part because pg 12 updates

func (*OnUpdate) SetSQLWithArgs added in v1.1.2

func (o *OnUpdate) SetSQLWithArgs(column, sql string, args ...interface{}) *OnUpdate

SetSQLWithArgs sets a field to a value that itself needs no escaping but may contain placeholders, to be filled with the optional args.

This is useful to build tings like `SET foo = foo || 'bar'` with the appropriate escaping.

func (*OnUpdate) Where added in v0.1.16

func (o *OnUpdate) Where(ec *ExpressionChain)

Where Adds Where condition to an update on conflict, does not return the OnUpdate because it is intended to be the last part of the expression.

type OrderByOperator added in v0.1.14

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

OrderByOperator unifies the `Asc` and `Desc` functions

func Asc added in v0.1.14

func Asc(columns ...string) *OrderByOperator

Asc declares OrderBy ascending, so least to greatest

func Desc added in v0.1.14

func Desc(columns ...string) *OrderByOperator

Desc declares OrderBy descending, or greatest to least

func (*OrderByOperator) Asc added in v0.1.14

func (o *OrderByOperator) Asc(columns ...string) *OrderByOperator

Asc allows for complex chained OrderBy clauses

func (*OrderByOperator) Desc added in v0.1.14

func (o *OrderByOperator) Desc(columns ...string) *OrderByOperator

Desc allows for complex chained OrderBy clauses

func (*OrderByOperator) String added in v0.1.14

func (o *OrderByOperator) String() string

String converts the operator to a string

type SelectArgument added in v0.1.16

type SelectArgument struct {
	Field string

	Args []interface{}
	// contains filtered or unexported fields
}

SelectArgument contains the components of a select column

func (SelectArgument) As added in v0.1.16

func (s SelectArgument) As(alias string) SelectArgument

As aliases the argument

Jump to

Keyboard shortcuts

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