mm

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Columns

func Columns(columns ...string) bob.Mod[*InsertAction]

Columns specifies the target columns for INSERT action. Names are quoted as SQL identifiers.

func Into

func Into(name any) bob.Mod[*dialect.MergeQuery]

Into specifies the target table for the MERGE statement

func IntoAs

func IntoAs(name any, alias string) bob.Mod[*dialect.MergeQuery]

IntoAs specifies the target table with an alias for the MERGE statement

func Only

func Only() bob.Mod[*dialect.MergeQuery]

Only specifies ONLY modifier for the target table

func OverridingSystem

func OverridingSystem() bob.Mod[*InsertAction]

OverridingSystem adds OVERRIDING SYSTEM VALUE for INSERT action Use when inserting into identity columns defined as GENERATED ALWAYS

func OverridingUser

func OverridingUser() bob.Mod[*InsertAction]

OverridingUser adds OVERRIDING USER VALUE for INSERT action Use when identity columns defined as GENERATED BY DEFAULT should use sequence values

func Returning

func Returning(clauses ...any) mods.Returning[*dialect.MergeQuery]

Returning adds a RETURNING clause

func Set

func Set(sets ...bob.Expression) bob.Mod[*UpdateAction]

Set adds raw SET expressions to the UPDATE action.

func SetCol

func SetCol(column string) mods.Set[*UpdateAction]

SetCol sets one column in MERGE ... THEN UPDATE SET. The column name is quoted automatically. For qualified names or other expressions on the LHS, use SetExpr.

func SetCols

func SetCols(columns ...string) clause.SetCols[*UpdateAction]

SetCols creates a multi-column setter: (columns...) = ROW(...) | (values...) | (subquery)

func SetExpr added in v0.45.0

func SetExpr(col bob.Expression) mods.Set[*UpdateAction]

SetExpr is like SetCol but the column LHS is any expression (e.g. psql.Quote("t", "col")).

func Values

func Values(values ...bob.Expression) bob.Mod[*InsertAction]

Values specifies the values for INSERT action Expressions can reference source data columns (for WHEN NOT MATCHED BY TARGET) Use psql.Quote("source_alias", "column") to reference source columns Use psql.Arg(value) for literal values Use psql.Raw("DEFAULT") for DEFAULT keyword

func With

func With(name string, columns ...string) dialect.CTEChain[*dialect.MergeQuery]

With starts a CTE. The name and column list are quoted as SQL identifiers.

Types

type InsertAction

type InsertAction struct {
	Columns    []string
	Values     []bob.Expression
	Overriding dialect.OverridingType
}

InsertAction collects options for WHEN ... THEN INSERT actions.

type UpdateAction

type UpdateAction struct {
	Set []any
}

UpdateAction collects SET clauses for WHEN ... THEN UPDATE actions.

func (*UpdateAction) AppendSet added in v0.44.0

func (u *UpdateAction) AppendSet(clauses ...any)

type UsingChain

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

func Using

func Using(source any) UsingChain

Using specifies the data source for the MERGE statement. Accepts a table name or a bob.Query (subquery).

func (UsingChain) As

func (u UsingChain) As(alias string) UsingChain

As sets an alias for the USING source.

func (UsingChain) On

func (u UsingChain) On(condition bob.Expression) bob.Mod[*dialect.MergeQuery]

On sets the join condition for the USING clause.

func (UsingChain) OnEQ

func (u UsingChain) OnEQ(left, right bob.Expression) bob.Mod[*dialect.MergeQuery]

OnEQ is a shorthand for On(left.EQ(right)).

func (UsingChain) Only

func (u UsingChain) Only() UsingChain

Only adds the ONLY modifier to the USING source.

type WhenMatchedChain

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

WhenMatchedChain builds WHEN MATCHED and WHEN NOT MATCHED BY SOURCE clauses. Available actions: UPDATE, DELETE, DO NOTHING.

func WhenMatched

func WhenMatched() WhenMatchedChain

WhenMatched creates a WHEN MATCHED clause chain

func (WhenMatchedChain) And

And adds a condition to the WHEN clause

func (WhenMatchedChain) ThenDelete

func (c WhenMatchedChain) ThenDelete() bob.Mod[*dialect.MergeQuery]

ThenDelete sets the action to DELETE

func (WhenMatchedChain) ThenDoNothing

func (c WhenMatchedChain) ThenDoNothing() bob.Mod[*dialect.MergeQuery]

ThenDoNothing sets the action to DO NOTHING

func (WhenMatchedChain) ThenUpdate

func (c WhenMatchedChain) ThenUpdate(sets ...bob.Mod[*UpdateAction]) bob.Mod[*dialect.MergeQuery]

ThenUpdate sets the action to UPDATE with SET clauses

type WhenNotMatchedBySourceChain added in v0.44.0

type WhenNotMatchedBySourceChain = WhenMatchedChain

WhenNotMatchedBySourceChain is an alias for WhenMatchedChain. It exists for API clarity so WhenNotMatchedBySource() returns a chain name that matches the clause kind, while reusing the same action set. Available actions: UPDATE, DELETE, DO NOTHING.

func WhenNotMatchedBySource

func WhenNotMatchedBySource() WhenNotMatchedBySourceChain

WhenNotMatchedBySource creates a WHEN NOT MATCHED BY SOURCE clause chain

type WhenNotMatchedChain

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

WhenNotMatchedChain builds WHEN NOT MATCHED [BY TARGET] clauses. Available actions: INSERT, DO NOTHING.

func WhenNotMatched

func WhenNotMatched() WhenNotMatchedChain

WhenNotMatched creates a WHEN NOT MATCHED (BY TARGET) clause chain

func WhenNotMatchedByTarget

func WhenNotMatchedByTarget() WhenNotMatchedChain

WhenNotMatchedByTarget is an alias for WhenNotMatched with explicit BY TARGET

func (WhenNotMatchedChain) And

And adds a condition to the WHEN clause

func (WhenNotMatchedChain) ThenDoNothing

func (c WhenNotMatchedChain) ThenDoNothing() bob.Mod[*dialect.MergeQuery]

ThenDoNothing sets the action to DO NOTHING

func (WhenNotMatchedChain) ThenInsert

func (c WhenNotMatchedChain) ThenInsert(mods ...bob.Mod[*InsertAction]) bob.Mod[*dialect.MergeQuery]

ThenInsert sets the action to INSERT

func (WhenNotMatchedChain) ThenInsertDefaultValues

func (c WhenNotMatchedChain) ThenInsertDefaultValues() bob.Mod[*dialect.MergeQuery]

ThenInsertDefaultValues sets the action to INSERT DEFAULT VALUES

Jump to

Keyboard shortcuts

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