orm

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorSystem    = "system"
	OperatorCronJob   = "cron_job"
	OperatorAnonymous = "anonymous"
)

System operators for audit tracking.

View Source
const (
	ExprOperator     = "?Operator"
	ExprTableColumns = "?TableColumns"
	ExprColumns      = "?Columns"
	ExprTablePKs     = "?TablePKs"
	ExprPKs          = "?PKs"
	ExprTableName    = "?TableName"
	ExprTableAlias   = "?TableAlias"
)

SQL expression placeholders for query building.

View Source
const (
	ColumnID            = "id"
	ColumnCreatedAt     = "created_at"
	ColumnUpdatedAt     = "updated_at"
	ColumnCreatedBy     = "created_by"
	ColumnUpdatedBy     = "updated_by"
	ColumnCreatedByName = "created_by_name"
	ColumnUpdatedByName = "updated_by_name"
)

Database column names for audit fields.

View Source
const (
	FieldID            = "ID"
	FieldCreatedAt     = "CreatedAt"
	FieldUpdatedAt     = "UpdatedAt"
	FieldCreatedBy     = "CreatedBy"
	FieldUpdatedBy     = "UpdatedBy"
	FieldCreatedByName = "CreatedByName"
	FieldUpdatedByName = "UpdatedByName"
)

Go struct field names corresponding to audit columns.

View Source
const PlaceholderKeyOperator = "Operator"

Placeholder key for named arguments in database queries.

Variables

View Source
var (
	ErrSubQuery                     = errors.New("cannot execute a subquery directly; use it as part of a parent query")
	ErrAggregateMissingArgs         = errors.New("aggregate function requires at least one argument")
	ErrDialectUnsupportedOperation  = errors.New("operation not supported by current database dialect")
	ErrAggregateUnsupportedFunction = errors.New("aggregate function not supported by current database dialect")
	ErrDialectHandlerMissing        = errors.New("no dialect handler available for requested operation")
	ErrMissingColumnOrExpression    = errors.New("order clause requires at least one column or expression")
	ErrModelMustBePointerToStruct   = errors.New("model must be a pointer to struct")
	ErrPrimaryKeyUnsupportedType    = errors.New("unsupported primary key type")
)
View Source
var DataType = DataTypeFactory{}

DataType is the global factory for creating data type definitions.

View Source
var Module = fx.Module(
	"vef:orm",
	fx.Provide(
		New,
	),
)

Module provides the Orm functionality for the VEF framework. It registers the database provider and logs initialization status.

Functions

func ApplySort

func ApplySort(query SelectQuery, orders []sortx.OrderSpec)

ApplySort applies the sort orders to the query.

func Names

func Names(ns ...string) schema.QueryAppender

Names returns a query appender that appends a list of names to the query.

Types

type AddColumnQuery

type AddColumnQuery interface {
	Executor
	TableTarget[AddColumnQuery]

	// Column defines the new column with data type and optional constraints.
	Column(name string, dataType DataTypeDef, constraints ...ColumnConstraint) AddColumnQuery
	// IfNotExists skips the addition when the column already exists.
	IfNotExists() AddColumnQuery
}

AddColumnQuery builds and executes ALTER TABLE ADD COLUMN queries.

type Applier

type Applier[T any] interface {
	// Apply executes the given modification functions on the query.
	Apply(fns ...ApplyFunc[T]) T
	// ApplyIf executes the modification functions only when condition is true.
	ApplyIf(condition bool, fns ...ApplyFunc[T]) T
}

Applier enables applying reusable query modifications, optionally conditioned on a boolean.

type ApplyFunc

type ApplyFunc[T any] func(T)

ApplyFunc is a reusable query modification function.

type ArrayAggBuilder

ArrayAggBuilder defines the ARRAY_AGG aggregate function builder.

type AuditConditionBuilder

type AuditConditionBuilder interface {
	// CreatedByEquals is a condition that checks if the created by column is equal to a value.
	CreatedByEquals(createdBy string, alias ...string) ConditionBuilder
	// OrCreatedByEquals is an OR condition that checks if the created by column is equal to a value.
	OrCreatedByEquals(createdBy string, alias ...string) ConditionBuilder
	// CreatedByEqualsSubQuery is a condition that checks if the created by column is equal to a subquery.
	CreatedByEqualsSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrCreatedByEqualsSubQuery is a condition that checks if the created by column is equal to a subquery.
	OrCreatedByEqualsSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// CreatedByEqualsAny is a condition that checks if the created by column is equal to any value returned by a subquery.
	CreatedByEqualsAny(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrCreatedByEqualsAny is a condition that checks if the created by column is equal to any value returned by a subquery.
	OrCreatedByEqualsAny(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// CreatedByEqualsAll is a condition that checks if the created by column is equal to all values returned by a subquery.
	CreatedByEqualsAll(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrCreatedByEqualsAll is a condition that checks if the created by column is equal to all values returned by a subquery.
	OrCreatedByEqualsAll(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// CreatedByEqualsCurrent is a condition that checks if the created by column is equal to the current user.
	CreatedByEqualsCurrent(alias ...string) ConditionBuilder
	// OrCreatedByEqualsCurrent is a condition that checks if the created by column is equal to the current user.
	OrCreatedByEqualsCurrent(alias ...string) ConditionBuilder
	// CreatedByNotEquals is a condition that checks if the created by column is not equal to a value.
	CreatedByNotEquals(createdBy string, alias ...string) ConditionBuilder
	// OrCreatedByNotEquals is a condition that checks if the created by column is not equal to a value.
	OrCreatedByNotEquals(createdBy string, alias ...string) ConditionBuilder
	// CreatedByNotEqualsSubQuery is a condition that checks if the created by column is not equal to a subquery.
	CreatedByNotEqualsSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrCreatedByNotEqualsSubQuery is a condition that checks if the created by column is not equal to a subquery.
	OrCreatedByNotEqualsSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// CreatedByNotEqualsAny is a condition that checks if the created by column is not equal to any value returned by a subquery.
	CreatedByNotEqualsAny(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrCreatedByNotEqualsAny is a condition that checks if the created by column is not equal to any value returned by a subquery.
	OrCreatedByNotEqualsAny(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// CreatedByNotEqualsAll is a condition that checks if the created by column is not equal to all values returned by a subquery.
	CreatedByNotEqualsAll(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrCreatedByNotEqualsAll is a condition that checks if the created by column is not equal to all values returned by a subquery.
	OrCreatedByNotEqualsAll(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// CreatedByNotEqualsCurrent is a condition that checks if the created by column is not equal to the current user.
	CreatedByNotEqualsCurrent(alias ...string) ConditionBuilder
	// OrCreatedByNotEqualsCurrent is a condition that checks if the created by column is not equal to the current user.
	OrCreatedByNotEqualsCurrent(alias ...string) ConditionBuilder
	// CreatedByIn is a condition that checks if the created by column is in a list of values.
	CreatedByIn(createdBys []string, alias ...string) ConditionBuilder
	// OrCreatedByIn is a condition that checks if the created by column is in a list of values.
	OrCreatedByIn(createdBys []string, alias ...string) ConditionBuilder
	// CreatedByInSubQuery is a condition that checks if the created by column is in a subquery.
	CreatedByInSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrCreatedByInSubQuery is an OR condition that checks if the created by column is in a subquery.
	OrCreatedByInSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// CreatedByNotIn is a condition that checks if the created by column is not in a list of values.
	CreatedByNotIn(createdBys []string, alias ...string) ConditionBuilder
	// OrCreatedByNotIn is a condition that checks if the created by column is not in a list of values.
	OrCreatedByNotIn(createdBys []string, alias ...string) ConditionBuilder
	// CreatedByNotInSubQuery is a condition that checks if the created by column is not in a subquery.
	CreatedByNotInSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrCreatedByNotInSubQuery is a condition that checks if the created by column is not in a subquery.
	OrCreatedByNotInSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// UpdatedByEquals is a condition that checks if the updated by column is equal to a value.
	UpdatedByEquals(updatedBy string, alias ...string) ConditionBuilder
	// OrUpdatedByEquals is a condition that checks if the updated by column is equal to a value.
	OrUpdatedByEquals(updatedBy string, alias ...string) ConditionBuilder
	// UpdatedByEqualsSubQuery is a condition that checks if the updated by column is equal to a subquery.
	UpdatedByEqualsSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrUpdatedByEqualsSubQuery is a condition that checks if the updated by column is equal to a subquery.
	OrUpdatedByEqualsSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// UpdatedByEqualsAny is a condition that checks if the updated by column is equal to any value returned by a subquery.
	UpdatedByEqualsAny(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrUpdatedByEqualsAny is a condition that checks if the updated by column is equal to any value returned by a subquery.
	OrUpdatedByEqualsAny(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// UpdatedByEqualsAll is a condition that checks if the updated by column is equal to all values returned by a subquery.
	UpdatedByEqualsAll(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrUpdatedByEqualsAll is a condition that checks if the updated by column is equal to all values returned by a subquery.
	OrUpdatedByEqualsAll(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// UpdatedByEqualsCurrent is a condition that checks if the updated by column is equal to the current user.
	UpdatedByEqualsCurrent(alias ...string) ConditionBuilder
	// OrUpdatedByEqualsCurrent is a condition that checks if the updated by column is equal to the current user.
	OrUpdatedByEqualsCurrent(alias ...string) ConditionBuilder
	// UpdatedByNotEquals is a condition that checks if the updated by column is not equal to a value.
	UpdatedByNotEquals(updatedBy string, alias ...string) ConditionBuilder
	// OrUpdatedByNotEquals is an OR condition that checks if the updated by column is not equal to a value.
	OrUpdatedByNotEquals(updatedBy string, alias ...string) ConditionBuilder
	// UpdatedByNotEqualsSubQuery is a condition that checks if the updated by column is not equal to a subquery.
	UpdatedByNotEqualsSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrUpdatedByNotEqualsSubQuery is a condition that checks if the updated by column is not equal to a subquery.
	OrUpdatedByNotEqualsSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// UpdatedByNotEqualsAny is a condition that checks if the updated by column is not equal to any value returned by a subquery.
	UpdatedByNotEqualsAny(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrUpdatedByNotEqualsAny is a condition that checks if the updated by column is not equal to any value returned by a subquery.
	OrUpdatedByNotEqualsAny(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// UpdatedByNotEqualsAll is a condition that checks if the updated by column is not equal to all values returned by a subquery.
	UpdatedByNotEqualsAll(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrUpdatedByNotEqualsAll is a condition that checks if the updated by column is not equal to all values returned by a subquery.
	OrUpdatedByNotEqualsAll(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// UpdatedByNotEqualsCurrent is a condition that checks if the updated by column is not equal to the current user.
	UpdatedByNotEqualsCurrent(alias ...string) ConditionBuilder
	// OrUpdatedByNotEqualsCurrent is a condition that checks if the updated by column is not equal to the current user.
	OrUpdatedByNotEqualsCurrent(alias ...string) ConditionBuilder
	// UpdatedByIn is a condition that checks if the updated by column is in a list of values.
	UpdatedByIn(updatedBys []string, alias ...string) ConditionBuilder
	// OrUpdatedByIn is an OR condition that checks if the updated by column is in a list of values.
	OrUpdatedByIn(updatedBys []string, alias ...string) ConditionBuilder
	// UpdatedByInSubQuery is a condition that checks if the updated by column is in a subquery.
	UpdatedByInSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrUpdatedByInSubQuery is a condition that checks if the updated by column is in a subquery.
	OrUpdatedByInSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// UpdatedByNotIn is a condition that checks if the updated by column is not in a list of values.
	UpdatedByNotIn(updatedBys []string, alias ...string) ConditionBuilder
	// OrUpdatedByNotIn is a condition that checks if the updated by column is not in a list of values.
	OrUpdatedByNotIn(updatedBys []string, alias ...string) ConditionBuilder
	// UpdatedByNotInSubQuery is a condition that checks if the updated by column is not in a subquery.
	UpdatedByNotInSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// OrUpdatedByNotInSubQuery is a condition that checks if the updated by column is not in a subquery.
	OrUpdatedByNotInSubQuery(builder func(query SelectQuery), alias ...string) ConditionBuilder
	// CreatedAtGreaterThan is a condition that checks if the created at column is greater than a value.
	CreatedAtGreaterThan(createdAt time.Time, alias ...string) ConditionBuilder
	// OrCreatedAtGreaterThan is a condition that checks if the created at column is greater than a value.
	OrCreatedAtGreaterThan(createdAt time.Time, alias ...string) ConditionBuilder
	// CreatedAtGreaterThanOrEqual is a condition that checks if the created at column is greater than or equal to a value.
	CreatedAtGreaterThanOrEqual(createdAt time.Time, alias ...string) ConditionBuilder
	// OrCreatedAtGreaterThanOrEqual is a condition that checks if the created at column is greater than or equal to a value.
	OrCreatedAtGreaterThanOrEqual(createdAt time.Time, alias ...string) ConditionBuilder
	// CreatedAtLessThan is a condition that checks if the created at column is less than a value.
	CreatedAtLessThan(createdAt time.Time, alias ...string) ConditionBuilder
	// OrCreatedAtLessThan is a condition that checks if the created at column is less than a value.
	OrCreatedAtLessThan(createdAt time.Time, alias ...string) ConditionBuilder
	// CreatedAtLessThanOrEqual is a condition that checks if the created at column is less than or equal to a value.
	CreatedAtLessThanOrEqual(createdAt time.Time, alias ...string) ConditionBuilder
	// OrCreatedAtLessThanOrEqual is a condition that checks if the created at column is less than or equal to a value.
	OrCreatedAtLessThanOrEqual(createdAt time.Time, alias ...string) ConditionBuilder
	// CreatedAtBetween is a condition that checks if the created at column is between two values.
	CreatedAtBetween(start, end time.Time, alias ...string) ConditionBuilder
	// OrCreatedAtBetween is a condition that checks if the created at column is between two values.
	OrCreatedAtBetween(start, end time.Time, alias ...string) ConditionBuilder
	// CreatedAtNotBetween is a condition that checks if the created at column is not between two values.
	CreatedAtNotBetween(start, end time.Time, alias ...string) ConditionBuilder
	// OrCreatedAtNotBetween is a condition that checks if the created at column is not between two values.
	OrCreatedAtNotBetween(start, end time.Time, alias ...string) ConditionBuilder
	// UpdatedAtGreaterThan is a condition that checks if the updated at column is greater than a value.
	UpdatedAtGreaterThan(updatedAt time.Time, alias ...string) ConditionBuilder
	// OrUpdatedAtGreaterThan is a condition that checks if the updated at column is greater than a value.
	OrUpdatedAtGreaterThan(updatedAt time.Time, alias ...string) ConditionBuilder
	// UpdatedAtGreaterThanOrEqual is a condition that checks if the updated at column is greater than or equal to a value.
	UpdatedAtGreaterThanOrEqual(updatedAt time.Time, alias ...string) ConditionBuilder
	// OrUpdatedAtGreaterThanOrEqual is a condition that checks if the updated at column is greater than or equal to a value.
	OrUpdatedAtGreaterThanOrEqual(updatedAt time.Time, alias ...string) ConditionBuilder
	// UpdatedAtLessThan is a condition that checks if the updated at column is less than a value.
	UpdatedAtLessThan(updatedAt time.Time, alias ...string) ConditionBuilder
	// OrUpdatedAtLessThan is a condition that checks if the updated at column is less than a value.
	OrUpdatedAtLessThan(updatedAt time.Time, alias ...string) ConditionBuilder
	// UpdatedAtLessThanOrEqual is a condition that checks if the updated at column is less than or equal to a value.
	UpdatedAtLessThanOrEqual(updatedAt time.Time, alias ...string) ConditionBuilder
	// OrUpdatedAtLessThanOrEqual is a condition that checks if the updated at column is less than or equal to a value.
	OrUpdatedAtLessThanOrEqual(updatedAt time.Time, alias ...string) ConditionBuilder
	// UpdatedAtBetween is a condition that checks if the updated at column is between two values.
	UpdatedAtBetween(start, end time.Time, alias ...string) ConditionBuilder
	// OrUpdatedAtBetween is a condition that checks if the updated at column is between two values.
	OrUpdatedAtBetween(start, end time.Time, alias ...string) ConditionBuilder
	// UpdatedAtNotBetween is a condition that checks if the updated at column is not between two values.
	UpdatedAtNotBetween(start, end time.Time, alias ...string) ConditionBuilder
	// OrUpdatedAtNotBetween is a condition that checks if the updated at column is not between two values.
	OrUpdatedAtNotBetween(start, end time.Time, alias ...string) ConditionBuilder
}

AuditConditionBuilder is a builder for audit conditions.

type AuditedModel

type AuditedModel struct {
	CreatedAt     timex.DateTime `json:"createdAt" bun:",notnull,type:timestamp,default:CURRENT_TIMESTAMP,skipupdate"`
	CreatedBy     string         `json:"createdBy" bun:",notnull,skipupdate" mold:"translate=user?"`
	CreatedByName string         `json:"createdByName" bun:",scanonly"`
	UpdatedAt     timex.DateTime `json:"updatedAt" bun:",notnull,type:timestamp,default:CURRENT_TIMESTAMP"`
	UpdatedBy     string         `json:"updatedBy" bun:",notnull" mold:"translate=user?"`
	UpdatedByName string         `json:"updatedByName" bun:",scanonly"`
}

AuditedModel contains full audit tracking fields (create + update).

type AvgBuilder

type AvgBuilder interface {
	BaseAggregate[AvgBuilder]
	DistinctableAggregate[AvgBuilder]
}

AvgBuilder defines the AVG aggregate function builder.

type BaseAggregate

type BaseAggregate[T any] interface {
	// Column specifies the column to aggregate.
	Column(column string) T
	// Expr specifies a raw expression to aggregate.
	Expr(expr any) T
	// Filter applies a FILTER clause to the aggregate expression.
	Filter(func(ConditionBuilder)) T
}

BaseAggregate defines the basic aggregate function interface with generic type support.

type BaseQueryBuilder

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

BaseQueryBuilder provides a common implementation for QueryBuilder interface. It can be embedded in concrete query types to reduce code duplication.

func (*BaseQueryBuilder) BuildCondition

func (b *BaseQueryBuilder) BuildCondition(builder func(ConditionBuilder)) interface {
	schema.QueryAppender
	ConditionBuilder
}

BuildCondition creates a condition builder for WHERE clauses.

func (*BaseQueryBuilder) BuildSubQuery

func (b *BaseQueryBuilder) BuildSubQuery(builder func(query SelectQuery)) *bun.SelectQuery

BuildSubQuery constructs a subquery using a builder function.

func (*BaseQueryBuilder) CreateSubQuery

func (b *BaseQueryBuilder) CreateSubQuery(subQuery *bun.SelectQuery) SelectQuery

CreateSubQuery creates a new subquery from the given bun.SelectQuery.

func (*BaseQueryBuilder) Dialect

func (b *BaseQueryBuilder) Dialect() schema.Dialect

Dialect returns the dialect of the current database connection.

func (*BaseQueryBuilder) ExprBuilder

func (b *BaseQueryBuilder) ExprBuilder() ExprBuilder

ExprBuilder returns the expression builder for this query.

func (*BaseQueryBuilder) GetTable

func (b *BaseQueryBuilder) GetTable() *schema.Table

GetTable returns the table information for the current query.

func (*BaseQueryBuilder) Query

func (b *BaseQueryBuilder) Query() bun.Query

Query returns the query of the current query instance.

func (*BaseQueryBuilder) String

func (b *BaseQueryBuilder) String() string

String returns the SQL query string.

type BaseWindowPartitionBuilder

type BaseWindowPartitionBuilder[T any] interface {
	// PartitionBy adds PARTITION BY columns to the window definition.
	PartitionBy(columns ...string) T
	// PartitionByExpr adds a raw PARTITION BY expression to the window definition.
	PartitionByExpr(expr any) T
	// OrderBy adds ORDER BY clauses with ascending direction.
	OrderBy(columns ...string) T
	// OrderByDesc adds ORDER BY clauses with descending direction.
	OrderByDesc(columns ...string) T
	// OrderByExpr adds an ORDER BY clause using a raw expression.
	OrderByExpr(expr any) T
}

BaseWindowPartitionBuilder defines the base window partition builder interface.

type BitAndBuilder

type BitAndBuilder interface {
	BaseAggregate[BitAndBuilder]
}

BitAndBuilder defines the BIT_AND aggregate function builder.

type BitOrBuilder

type BitOrBuilder interface {
	BaseAggregate[BitOrBuilder]
}

BitOrBuilder defines the BIT_OR aggregate function builder.

type BoolAndBuilder

type BoolAndBuilder interface {
	BaseAggregate[BoolAndBuilder]
}

BoolAndBuilder defines the BOOL_AND aggregate function builder.

type BoolOrBuilder

type BoolOrBuilder interface {
	BaseAggregate[BoolOrBuilder]
}

BoolOrBuilder defines the BOOL_OR aggregate function builder.

type BunAddColumnQuery

type BunAddColumnQuery struct {
	*BaseQueryBuilder
	// contains filtered or unexported fields
}

BunAddColumnQuery implements the AddColumnQuery interface with type-safe DDL operations.

func NewAddColumnQuery

func NewAddColumnQuery(db *BunDB) *BunAddColumnQuery

NewAddColumnQuery creates a new AddColumnQuery with BaseQueryBuilder for expression support.

func (*BunAddColumnQuery) Column

func (q *BunAddColumnQuery) Column(name string, dataType DataTypeDef, constraints ...ColumnConstraint) AddColumnQuery

func (*BunAddColumnQuery) Exec

func (q *BunAddColumnQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunAddColumnQuery) IfNotExists

func (q *BunAddColumnQuery) IfNotExists() AddColumnQuery

func (*BunAddColumnQuery) Model

func (q *BunAddColumnQuery) Model(model any) AddColumnQuery

func (*BunAddColumnQuery) Table

func (q *BunAddColumnQuery) Table(tables ...string) AddColumnQuery

type BunCreateIndexQuery

type BunCreateIndexQuery struct {
	*BaseQueryBuilder
	// contains filtered or unexported fields
}

BunCreateIndexQuery implements the CreateIndexQuery interface with type-safe DDL operations.

func NewCreateIndexQuery

func NewCreateIndexQuery(db *BunDB) *BunCreateIndexQuery

NewCreateIndexQuery creates a new CreateIndexQuery with BaseQueryBuilder for expression support.

func (*BunCreateIndexQuery) Column

func (q *BunCreateIndexQuery) Column(columns ...string) CreateIndexQuery

func (*BunCreateIndexQuery) ColumnExpr

func (q *BunCreateIndexQuery) ColumnExpr(builder func(ExprBuilder) any) CreateIndexQuery

func (*BunCreateIndexQuery) Concurrently

func (q *BunCreateIndexQuery) Concurrently() CreateIndexQuery

func (*BunCreateIndexQuery) ExcludeColumn

func (q *BunCreateIndexQuery) ExcludeColumn(columns ...string) CreateIndexQuery

func (*BunCreateIndexQuery) Exec

func (q *BunCreateIndexQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunCreateIndexQuery) IfNotExists

func (q *BunCreateIndexQuery) IfNotExists() CreateIndexQuery

func (*BunCreateIndexQuery) Include

func (q *BunCreateIndexQuery) Include(columns ...string) CreateIndexQuery

func (*BunCreateIndexQuery) Index

func (*BunCreateIndexQuery) Model

func (q *BunCreateIndexQuery) Model(model any) CreateIndexQuery

func (*BunCreateIndexQuery) Table

func (q *BunCreateIndexQuery) Table(tables ...string) CreateIndexQuery

func (*BunCreateIndexQuery) Unique

func (*BunCreateIndexQuery) Using

func (*BunCreateIndexQuery) Where

func (q *BunCreateIndexQuery) Where(builder func(ConditionBuilder)) CreateIndexQuery

type BunCreateTableQuery

type BunCreateTableQuery struct {
	*BaseQueryBuilder
	// contains filtered or unexported fields
}

BunCreateTableQuery implements the CreateTableQuery interface with type-safe DDL operations.

func NewCreateTableQuery

func NewCreateTableQuery(db *BunDB) *BunCreateTableQuery

NewCreateTableQuery creates a new CreateTableQuery with BaseQueryBuilder for expression support.

func (*BunCreateTableQuery) Check

func (q *BunCreateTableQuery) Check(builder func(CheckBuilder)) CreateTableQuery

func (*BunCreateTableQuery) Column

func (q *BunCreateTableQuery) Column(name string, dataType DataTypeDef, constraints ...ColumnConstraint) CreateTableQuery

func (*BunCreateTableQuery) DefaultVarChar

func (q *BunCreateTableQuery) DefaultVarChar(n int) CreateTableQuery

func (*BunCreateTableQuery) Exec

func (q *BunCreateTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunCreateTableQuery) ForeignKey

func (q *BunCreateTableQuery) ForeignKey(builder func(ForeignKeyBuilder)) CreateTableQuery

func (*BunCreateTableQuery) IfNotExists

func (q *BunCreateTableQuery) IfNotExists() CreateTableQuery

func (*BunCreateTableQuery) Model

func (q *BunCreateTableQuery) Model(model any) CreateTableQuery

func (*BunCreateTableQuery) PartitionBy

func (q *BunCreateTableQuery) PartitionBy(strategy PartitionStrategy, columns ...string) CreateTableQuery

func (*BunCreateTableQuery) PrimaryKey

func (q *BunCreateTableQuery) PrimaryKey(builder func(PrimaryKeyBuilder)) CreateTableQuery

func (*BunCreateTableQuery) String

func (q *BunCreateTableQuery) String() string

func (*BunCreateTableQuery) Table

func (q *BunCreateTableQuery) Table(tables ...string) CreateTableQuery

func (*BunCreateTableQuery) TableSpace

func (q *BunCreateTableQuery) TableSpace(tableSpace string) CreateTableQuery

func (*BunCreateTableQuery) Temp

func (*BunCreateTableQuery) Unique

func (q *BunCreateTableQuery) Unique(builder func(UniqueBuilder)) CreateTableQuery

func (*BunCreateTableQuery) WithForeignKeys

func (q *BunCreateTableQuery) WithForeignKeys() CreateTableQuery

type BunDB

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

BunDB is a wrapper around the bun.DB type.

func (*BunDB) BeginTx

func (d *BunDB) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)

func (*BunDB) Connection

func (d *BunDB) Connection(ctx context.Context) (*sql.Conn, error)

func (*BunDB) ModelPKFields

func (d *BunDB) ModelPKFields(model any) []*PKField

func (*BunDB) ModelPKs

func (d *BunDB) ModelPKs(model any) (map[string]any, error)

func (*BunDB) NewAddColumn

func (d *BunDB) NewAddColumn() AddColumnQuery

func (*BunDB) NewCreateIndex

func (d *BunDB) NewCreateIndex() CreateIndexQuery

func (*BunDB) NewCreateTable

func (d *BunDB) NewCreateTable() CreateTableQuery

func (*BunDB) NewDelete

func (d *BunDB) NewDelete() DeleteQuery

func (*BunDB) NewDropColumn

func (d *BunDB) NewDropColumn() DropColumnQuery

func (*BunDB) NewDropIndex

func (d *BunDB) NewDropIndex() DropIndexQuery

func (*BunDB) NewDropTable

func (d *BunDB) NewDropTable() DropTableQuery

func (*BunDB) NewInsert

func (d *BunDB) NewInsert() InsertQuery

func (*BunDB) NewMerge

func (d *BunDB) NewMerge() MergeQuery

func (*BunDB) NewRaw

func (d *BunDB) NewRaw(query string, args ...any) RawQuery

func (*BunDB) NewSelect

func (d *BunDB) NewSelect() SelectQuery

func (*BunDB) NewTruncateTable

func (d *BunDB) NewTruncateTable() TruncateTableQuery

func (*BunDB) NewUpdate

func (d *BunDB) NewUpdate() UpdateQuery

func (*BunDB) RegisterModel

func (d *BunDB) RegisterModel(models ...any)

func (*BunDB) ResetModel

func (d *BunDB) ResetModel(ctx context.Context, models ...any) error

func (*BunDB) RunInReadOnlyTX

func (d *BunDB) RunInReadOnlyTX(ctx context.Context, fn func(context.Context, DB) error) error

func (*BunDB) RunInTX

func (d *BunDB) RunInTX(ctx context.Context, fn func(context.Context, DB) error) error

func (*BunDB) ScanRow

func (d *BunDB) ScanRow(ctx context.Context, rows *sql.Rows, dest ...any) error

func (*BunDB) ScanRows

func (d *BunDB) ScanRows(ctx context.Context, rows *sql.Rows, dest ...any) error

func (*BunDB) TableOf

func (d *BunDB) TableOf(model any) *schema.Table

func (*BunDB) WithNamedArg

func (d *BunDB) WithNamedArg(name string, value any) DB

type BunDeleteQuery

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

BunDeleteQuery is the concrete implementation of DeleteQuery interface. It wraps bun.DeleteQuery and provides additional functionality for expression building.

func NewDeleteQuery

func NewDeleteQuery(db *BunDB) *BunDeleteQuery

NewDeleteQuery creates a new DeleteQuery instance with the provided database instance. It initializes the query builders and sets up the table schema context for proper query building.

func (*BunDeleteQuery) Apply

func (q *BunDeleteQuery) Apply(fns ...ApplyFunc[DeleteQuery]) DeleteQuery

func (*BunDeleteQuery) ApplyIf

func (q *BunDeleteQuery) ApplyIf(condition bool, fns ...ApplyFunc[DeleteQuery]) DeleteQuery

func (*BunDeleteQuery) DB

func (q *BunDeleteQuery) DB() DB

func (*BunDeleteQuery) Exec

func (q *BunDeleteQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunDeleteQuery) ForceDelete

func (q *BunDeleteQuery) ForceDelete() DeleteQuery

func (*BunDeleteQuery) IncludeDeleted

func (q *BunDeleteQuery) IncludeDeleted() DeleteQuery

func (*BunDeleteQuery) Limit

func (q *BunDeleteQuery) Limit(limit int) DeleteQuery

func (*BunDeleteQuery) Model

func (q *BunDeleteQuery) Model(model any) DeleteQuery

func (*BunDeleteQuery) ModelTable

func (q *BunDeleteQuery) ModelTable(name string, alias ...string) DeleteQuery

func (*BunDeleteQuery) OrderBy

func (q *BunDeleteQuery) OrderBy(columns ...string) DeleteQuery

func (*BunDeleteQuery) OrderByDesc

func (q *BunDeleteQuery) OrderByDesc(columns ...string) DeleteQuery

func (*BunDeleteQuery) OrderByExpr

func (q *BunDeleteQuery) OrderByExpr(builder func(ExprBuilder) any) DeleteQuery

func (*BunDeleteQuery) Returning

func (q *BunDeleteQuery) Returning(columns ...string) DeleteQuery

func (*BunDeleteQuery) ReturningAll

func (q *BunDeleteQuery) ReturningAll() DeleteQuery

func (*BunDeleteQuery) ReturningNone

func (q *BunDeleteQuery) ReturningNone() DeleteQuery

func (*BunDeleteQuery) Scan

func (q *BunDeleteQuery) Scan(ctx context.Context, dest ...any) error

func (*BunDeleteQuery) Table

func (q *BunDeleteQuery) Table(name string, alias ...string) DeleteQuery

func (*BunDeleteQuery) TableExpr

func (q *BunDeleteQuery) TableExpr(builder func(ExprBuilder) any, alias ...string) DeleteQuery

func (*BunDeleteQuery) TableFrom

func (q *BunDeleteQuery) TableFrom(model any, alias ...string) DeleteQuery

func (*BunDeleteQuery) TableSubQuery

func (q *BunDeleteQuery) TableSubQuery(builder func(SelectQuery), alias ...string) DeleteQuery

func (*BunDeleteQuery) Where

func (q *BunDeleteQuery) Where(builder func(ConditionBuilder)) DeleteQuery

func (*BunDeleteQuery) WhereDeleted

func (q *BunDeleteQuery) WhereDeleted() DeleteQuery

func (*BunDeleteQuery) WherePK

func (q *BunDeleteQuery) WherePK(columns ...string) DeleteQuery

func (*BunDeleteQuery) With

func (q *BunDeleteQuery) With(name string, builder func(SelectQuery)) DeleteQuery

func (*BunDeleteQuery) WithRecursive

func (q *BunDeleteQuery) WithRecursive(name string, builder func(SelectQuery)) DeleteQuery

func (*BunDeleteQuery) WithValues

func (q *BunDeleteQuery) WithValues(name string, model any, withOrder ...bool) DeleteQuery

type BunDropColumnQuery

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

BunDropColumnQuery implements the DropColumnQuery interface.

func NewDropColumnQuery

func NewDropColumnQuery(db *BunDB) *BunDropColumnQuery

NewDropColumnQuery creates a new DropColumnQuery.

func (*BunDropColumnQuery) Column

func (q *BunDropColumnQuery) Column(columns ...string) DropColumnQuery

func (*BunDropColumnQuery) Exec

func (q *BunDropColumnQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunDropColumnQuery) Model

func (q *BunDropColumnQuery) Model(model any) DropColumnQuery

func (*BunDropColumnQuery) Table

func (q *BunDropColumnQuery) Table(tables ...string) DropColumnQuery

type BunDropIndexQuery

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

BunDropIndexQuery implements the DropIndexQuery interface.

func NewDropIndexQuery

func NewDropIndexQuery(db *BunDB) *BunDropIndexQuery

NewDropIndexQuery creates a new DropIndexQuery.

func (*BunDropIndexQuery) Cascade

func (q *BunDropIndexQuery) Cascade() DropIndexQuery

func (*BunDropIndexQuery) Concurrently

func (q *BunDropIndexQuery) Concurrently() DropIndexQuery

func (*BunDropIndexQuery) Exec

func (q *BunDropIndexQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunDropIndexQuery) IfExists

func (q *BunDropIndexQuery) IfExists() DropIndexQuery

func (*BunDropIndexQuery) Index

func (q *BunDropIndexQuery) Index(name string) DropIndexQuery

func (*BunDropIndexQuery) Restrict

func (q *BunDropIndexQuery) Restrict() DropIndexQuery

type BunDropTableQuery

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

BunDropTableQuery implements the DropTableQuery interface.

func NewDropTableQuery

func NewDropTableQuery(db *BunDB) *BunDropTableQuery

NewDropTableQuery creates a new DropTableQuery.

func (*BunDropTableQuery) Cascade

func (q *BunDropTableQuery) Cascade() DropTableQuery

func (*BunDropTableQuery) Exec

func (q *BunDropTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunDropTableQuery) IfExists

func (q *BunDropTableQuery) IfExists() DropTableQuery

func (*BunDropTableQuery) Model

func (q *BunDropTableQuery) Model(model any) DropTableQuery

func (*BunDropTableQuery) Restrict

func (q *BunDropTableQuery) Restrict() DropTableQuery

func (*BunDropTableQuery) String

func (q *BunDropTableQuery) String() string

func (*BunDropTableQuery) Table

func (q *BunDropTableQuery) Table(tables ...string) DropTableQuery

type BunInsertQuery

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

BunInsertQuery is the concrete implementation of InsertQuery interface. It wraps bun.InsertQuery and provides additional functionality for expression building.

func NewInsertQuery

func NewInsertQuery(db *BunDB) *BunInsertQuery

NewInsertQuery creates a new InsertQuery instance with the provided database instance. It initializes the query builders and sets up the table schema context for proper query building.

func (*BunInsertQuery) Apply

func (q *BunInsertQuery) Apply(fns ...ApplyFunc[InsertQuery]) InsertQuery

func (*BunInsertQuery) ApplyIf

func (q *BunInsertQuery) ApplyIf(condition bool, fns ...ApplyFunc[InsertQuery]) InsertQuery

func (*BunInsertQuery) Column

func (q *BunInsertQuery) Column(name string, value any) InsertQuery

func (*BunInsertQuery) ColumnExpr

func (q *BunInsertQuery) ColumnExpr(name string, builder func(ExprBuilder) any) InsertQuery

func (*BunInsertQuery) DB

func (q *BunInsertQuery) DB() DB

func (*BunInsertQuery) Exclude

func (q *BunInsertQuery) Exclude(columns ...string) InsertQuery

func (*BunInsertQuery) ExcludeAll

func (q *BunInsertQuery) ExcludeAll() InsertQuery

func (*BunInsertQuery) Exec

func (q *BunInsertQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunInsertQuery) Model

func (q *BunInsertQuery) Model(model any) InsertQuery

func (*BunInsertQuery) ModelTable

func (q *BunInsertQuery) ModelTable(name string, alias ...string) InsertQuery

func (*BunInsertQuery) OnConflict

func (q *BunInsertQuery) OnConflict(builder func(ConflictBuilder)) InsertQuery

OnConflict configures conflict handling via a dialect-aware builder.

func (*BunInsertQuery) Returning

func (q *BunInsertQuery) Returning(columns ...string) InsertQuery

func (*BunInsertQuery) ReturningAll

func (q *BunInsertQuery) ReturningAll() InsertQuery

func (*BunInsertQuery) ReturningNone

func (q *BunInsertQuery) ReturningNone() InsertQuery

func (*BunInsertQuery) Scan

func (q *BunInsertQuery) Scan(ctx context.Context, dest ...any) error

func (*BunInsertQuery) Select

func (q *BunInsertQuery) Select(columns ...string) InsertQuery

func (*BunInsertQuery) SelectAll

func (q *BunInsertQuery) SelectAll() InsertQuery

func (*BunInsertQuery) Table

func (q *BunInsertQuery) Table(name string, alias ...string) InsertQuery

func (*BunInsertQuery) TableExpr

func (q *BunInsertQuery) TableExpr(builder func(ExprBuilder) any, alias ...string) InsertQuery

func (*BunInsertQuery) TableFrom

func (q *BunInsertQuery) TableFrom(model any, alias ...string) InsertQuery

func (*BunInsertQuery) TableSubQuery

func (q *BunInsertQuery) TableSubQuery(builder func(SelectQuery), alias ...string) InsertQuery

func (*BunInsertQuery) With

func (q *BunInsertQuery) With(name string, builder func(SelectQuery)) InsertQuery

func (*BunInsertQuery) WithRecursive

func (q *BunInsertQuery) WithRecursive(name string, builder func(SelectQuery)) InsertQuery

func (*BunInsertQuery) WithValues

func (q *BunInsertQuery) WithValues(name string, model any, withOrder ...bool) InsertQuery

type BunMergeQuery

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

BunMergeQuery is the concrete implementation of MergeQuery interface. It wraps bun.MergeQuery and provides additional functionality for expression building.

func NewMergeQuery

func NewMergeQuery(db *BunDB) *BunMergeQuery

NewMergeQuery creates a new MergeQuery instance with the provided database instance. It initializes the query builders and sets up the table schema context for proper query building.

func (*BunMergeQuery) Apply

func (q *BunMergeQuery) Apply(fns ...ApplyFunc[MergeQuery]) MergeQuery

func (*BunMergeQuery) ApplyIf

func (q *BunMergeQuery) ApplyIf(condition bool, fns ...ApplyFunc[MergeQuery]) MergeQuery

func (*BunMergeQuery) DB

func (q *BunMergeQuery) DB() DB

func (*BunMergeQuery) Exec

func (q *BunMergeQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunMergeQuery) Model

func (q *BunMergeQuery) Model(model any) MergeQuery

func (*BunMergeQuery) ModelTable

func (q *BunMergeQuery) ModelTable(name string, alias ...string) MergeQuery

func (*BunMergeQuery) On

func (q *BunMergeQuery) On(builder func(ConditionBuilder)) MergeQuery

func (*BunMergeQuery) Returning

func (q *BunMergeQuery) Returning(columns ...string) MergeQuery

func (*BunMergeQuery) ReturningAll

func (q *BunMergeQuery) ReturningAll() MergeQuery

func (*BunMergeQuery) ReturningNone

func (q *BunMergeQuery) ReturningNone() MergeQuery

func (*BunMergeQuery) Scan

func (q *BunMergeQuery) Scan(ctx context.Context, dest ...any) error

func (*BunMergeQuery) Table

func (q *BunMergeQuery) Table(name string, alias ...string) MergeQuery

func (*BunMergeQuery) TableExpr

func (q *BunMergeQuery) TableExpr(builder func(ExprBuilder) any, alias ...string) MergeQuery

func (*BunMergeQuery) TableFrom

func (q *BunMergeQuery) TableFrom(model any, alias ...string) MergeQuery

func (*BunMergeQuery) TableSubQuery

func (q *BunMergeQuery) TableSubQuery(builder func(SelectQuery), alias ...string) MergeQuery

func (*BunMergeQuery) Using

func (q *BunMergeQuery) Using(model any, alias ...string) MergeQuery

func (*BunMergeQuery) UsingExpr

func (q *BunMergeQuery) UsingExpr(builder func(ExprBuilder) any, alias ...string) MergeQuery

func (*BunMergeQuery) UsingSubQuery

func (q *BunMergeQuery) UsingSubQuery(builder func(SelectQuery), alias ...string) MergeQuery

func (*BunMergeQuery) UsingTable

func (q *BunMergeQuery) UsingTable(table string, alias ...string) MergeQuery

func (*BunMergeQuery) WhenMatched

func (q *BunMergeQuery) WhenMatched(builder ...func(ConditionBuilder)) MergeWhenBuilder

func (*BunMergeQuery) WhenNotMatched

func (q *BunMergeQuery) WhenNotMatched(builder ...func(ConditionBuilder)) MergeWhenBuilder

func (*BunMergeQuery) WhenNotMatchedBySource

func (q *BunMergeQuery) WhenNotMatchedBySource(builder ...func(ConditionBuilder)) MergeWhenBuilder

func (*BunMergeQuery) WhenNotMatchedByTarget

func (q *BunMergeQuery) WhenNotMatchedByTarget(builder ...func(ConditionBuilder)) MergeWhenBuilder

func (*BunMergeQuery) With

func (q *BunMergeQuery) With(name string, builder func(SelectQuery)) MergeQuery

func (*BunMergeQuery) WithRecursive

func (q *BunMergeQuery) WithRecursive(name string, builder func(SelectQuery)) MergeQuery

func (*BunMergeQuery) WithValues

func (q *BunMergeQuery) WithValues(name string, model any, withOrder ...bool) MergeQuery

type BunSelectQuery

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

BunSelectQuery is the concrete implementation of SelectQuery interface. It wraps bun.SelectQuery and provides additional functionality for expression building.

func NewSelectQuery

func NewSelectQuery(db *BunDB) *BunSelectQuery

NewSelectQuery creates a new SelectQuery instance with the provided database instance. It initializes the query builders and sets up the table schema context for proper query building.

func (*BunSelectQuery) Apply

func (q *BunSelectQuery) Apply(fns ...ApplyFunc[SelectQuery]) SelectQuery

func (*BunSelectQuery) ApplyIf

func (q *BunSelectQuery) ApplyIf(condition bool, fns ...ApplyFunc[SelectQuery]) SelectQuery

func (*BunSelectQuery) Count

func (q *BunSelectQuery) Count(ctx context.Context) (int64, error)

func (*BunSelectQuery) CrossJoin

func (q *BunSelectQuery) CrossJoin(model any, alias ...string) SelectQuery

func (*BunSelectQuery) CrossJoinExpr

func (q *BunSelectQuery) CrossJoinExpr(eBuilder func(ExprBuilder) any, alias ...string) SelectQuery

func (*BunSelectQuery) CrossJoinSubQuery

func (q *BunSelectQuery) CrossJoinSubQuery(sqBuilder func(query SelectQuery), alias ...string) SelectQuery

func (*BunSelectQuery) CrossJoinTable

func (q *BunSelectQuery) CrossJoinTable(name string, alias ...string) SelectQuery

func (*BunSelectQuery) DB

func (q *BunSelectQuery) DB() DB

func (*BunSelectQuery) Distinct

func (q *BunSelectQuery) Distinct() SelectQuery

func (*BunSelectQuery) DistinctOnColumns

func (q *BunSelectQuery) DistinctOnColumns(columns ...string) SelectQuery

func (*BunSelectQuery) DistinctOnExpr

func (q *BunSelectQuery) DistinctOnExpr(builder func(ExprBuilder) any) SelectQuery

func (*BunSelectQuery) Except

func (q *BunSelectQuery) Except(builder func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) ExceptAll

func (q *BunSelectQuery) ExceptAll(builder func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) Exclude

func (q *BunSelectQuery) Exclude(columns ...string) SelectQuery

func (*BunSelectQuery) ExcludeAll

func (q *BunSelectQuery) ExcludeAll() SelectQuery

func (*BunSelectQuery) Exec

func (q *BunSelectQuery) Exec(ctx context.Context, dest ...any) (res sql.Result, err error)

func (*BunSelectQuery) Exists

func (q *BunSelectQuery) Exists(ctx context.Context) (bool, error)

func (*BunSelectQuery) ForKeyShare

func (q *BunSelectQuery) ForKeyShare(tables ...any) SelectQuery

func (*BunSelectQuery) ForKeyShareNoWait

func (q *BunSelectQuery) ForKeyShareNoWait(tables ...any) SelectQuery

func (*BunSelectQuery) ForKeyShareSkipLocked

func (q *BunSelectQuery) ForKeyShareSkipLocked(tables ...any) SelectQuery

func (*BunSelectQuery) ForNoKeyUpdate

func (q *BunSelectQuery) ForNoKeyUpdate(tables ...any) SelectQuery

func (*BunSelectQuery) ForNoKeyUpdateNoWait

func (q *BunSelectQuery) ForNoKeyUpdateNoWait(tables ...any) SelectQuery

func (*BunSelectQuery) ForNoKeyUpdateSkipLocked

func (q *BunSelectQuery) ForNoKeyUpdateSkipLocked(tables ...any) SelectQuery

func (*BunSelectQuery) ForShare

func (q *BunSelectQuery) ForShare(tables ...any) SelectQuery

func (*BunSelectQuery) ForShareNoWait

func (q *BunSelectQuery) ForShareNoWait(tables ...any) SelectQuery

func (*BunSelectQuery) ForShareSkipLocked

func (q *BunSelectQuery) ForShareSkipLocked(tables ...any) SelectQuery

func (*BunSelectQuery) ForUpdate

func (q *BunSelectQuery) ForUpdate(tables ...any) SelectQuery

func (*BunSelectQuery) ForUpdateNoWait

func (q *BunSelectQuery) ForUpdateNoWait(tables ...any) SelectQuery

func (*BunSelectQuery) ForUpdateSkipLocked

func (q *BunSelectQuery) ForUpdateSkipLocked(tables ...any) SelectQuery

func (*BunSelectQuery) FullJoin

func (q *BunSelectQuery) FullJoin(model any, builder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) FullJoinExpr

func (q *BunSelectQuery) FullJoinExpr(eBuilder func(ExprBuilder) any, cBuilder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) FullJoinSubQuery

func (q *BunSelectQuery) FullJoinSubQuery(sqBuilder func(query SelectQuery), cBuilder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) FullJoinTable

func (q *BunSelectQuery) FullJoinTable(name string, builder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) GroupBy

func (q *BunSelectQuery) GroupBy(columns ...string) SelectQuery

func (*BunSelectQuery) GroupByExpr

func (q *BunSelectQuery) GroupByExpr(builder func(ExprBuilder) any) SelectQuery

func (*BunSelectQuery) Having

func (q *BunSelectQuery) Having(builder func(ConditionBuilder)) SelectQuery

func (*BunSelectQuery) IncludeDeleted

func (q *BunSelectQuery) IncludeDeleted() SelectQuery

func (*BunSelectQuery) Intersect

func (q *BunSelectQuery) Intersect(builder func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) IntersectAll

func (q *BunSelectQuery) IntersectAll(builder func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) Join

func (q *BunSelectQuery) Join(model any, builder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) JoinExpr

func (q *BunSelectQuery) JoinExpr(eBuilder func(ExprBuilder) any, cBuilder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) JoinRelations

func (q *BunSelectQuery) JoinRelations(specs ...*RelationSpec) SelectQuery

func (*BunSelectQuery) JoinSubQuery

func (q *BunSelectQuery) JoinSubQuery(sqBuilder func(query SelectQuery), cBuilder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) JoinTable

func (q *BunSelectQuery) JoinTable(name string, builder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) LeftJoin

func (q *BunSelectQuery) LeftJoin(model any, builder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) LeftJoinExpr

func (q *BunSelectQuery) LeftJoinExpr(eBuilder func(ExprBuilder) any, cBuilder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) LeftJoinSubQuery

func (q *BunSelectQuery) LeftJoinSubQuery(sqBuilder func(query SelectQuery), cBuilder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) LeftJoinTable

func (q *BunSelectQuery) LeftJoinTable(name string, builder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) Limit

func (q *BunSelectQuery) Limit(limit int) SelectQuery

func (*BunSelectQuery) Model

func (q *BunSelectQuery) Model(model any) SelectQuery

func (*BunSelectQuery) ModelTable

func (q *BunSelectQuery) ModelTable(name string, alias ...string) SelectQuery

func (*BunSelectQuery) Offset

func (q *BunSelectQuery) Offset(offset int) SelectQuery

func (*BunSelectQuery) OrderBy

func (q *BunSelectQuery) OrderBy(columns ...string) SelectQuery

func (*BunSelectQuery) OrderByDesc

func (q *BunSelectQuery) OrderByDesc(columns ...string) SelectQuery

func (*BunSelectQuery) OrderByExpr

func (q *BunSelectQuery) OrderByExpr(builder func(ExprBuilder) any) SelectQuery

func (*BunSelectQuery) Paginate

func (q *BunSelectQuery) Paginate(pageable page.Pageable) SelectQuery

func (*BunSelectQuery) Relation

func (q *BunSelectQuery) Relation(name string, apply ...func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) RightJoin

func (q *BunSelectQuery) RightJoin(model any, builder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) RightJoinExpr

func (q *BunSelectQuery) RightJoinExpr(eBuilder func(ExprBuilder) any, cBuilder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) RightJoinSubQuery

func (q *BunSelectQuery) RightJoinSubQuery(sqBuilder func(query SelectQuery), cBuilder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) RightJoinTable

func (q *BunSelectQuery) RightJoinTable(name string, builder func(ConditionBuilder), alias ...string) SelectQuery

func (*BunSelectQuery) Rows

func (q *BunSelectQuery) Rows(ctx context.Context) (rows *sql.Rows, err error)

func (*BunSelectQuery) Scan

func (q *BunSelectQuery) Scan(ctx context.Context, dest ...any) (err error)

func (*BunSelectQuery) ScanAndCount

func (q *BunSelectQuery) ScanAndCount(ctx context.Context, dest ...any) (int64, error)

func (*BunSelectQuery) Select

func (q *BunSelectQuery) Select(columns ...string) SelectQuery

func (*BunSelectQuery) SelectAll

func (q *BunSelectQuery) SelectAll() SelectQuery

func (*BunSelectQuery) SelectAs

func (q *BunSelectQuery) SelectAs(column, alias string) SelectQuery

func (*BunSelectQuery) SelectExpr

func (q *BunSelectQuery) SelectExpr(builder func(ExprBuilder) any, alias ...string) SelectQuery

func (*BunSelectQuery) SelectModelColumns

func (q *BunSelectQuery) SelectModelColumns() SelectQuery

func (*BunSelectQuery) SelectModelPKs

func (q *BunSelectQuery) SelectModelPKs() SelectQuery

func (*BunSelectQuery) Table

func (q *BunSelectQuery) Table(name string, alias ...string) SelectQuery

func (*BunSelectQuery) TableExpr

func (q *BunSelectQuery) TableExpr(builder func(ExprBuilder) any, alias ...string) SelectQuery

func (*BunSelectQuery) TableFrom

func (q *BunSelectQuery) TableFrom(model any, alias ...string) SelectQuery

func (*BunSelectQuery) TableSubQuery

func (q *BunSelectQuery) TableSubQuery(builder func(query SelectQuery), alias ...string) SelectQuery

func (*BunSelectQuery) Union

func (q *BunSelectQuery) Union(builder func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) UnionAll

func (q *BunSelectQuery) UnionAll(builder func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) Where

func (q *BunSelectQuery) Where(builder func(ConditionBuilder)) SelectQuery

func (*BunSelectQuery) WhereDeleted

func (q *BunSelectQuery) WhereDeleted() SelectQuery

func (*BunSelectQuery) WherePK

func (q *BunSelectQuery) WherePK(columns ...string) SelectQuery

func (*BunSelectQuery) With

func (q *BunSelectQuery) With(name string, builder func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) WithRecursive

func (q *BunSelectQuery) WithRecursive(name string, builder func(query SelectQuery)) SelectQuery

func (*BunSelectQuery) WithValues

func (q *BunSelectQuery) WithValues(name string, model any, withOrder ...bool) SelectQuery

type BunTruncateTableQuery

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

BunTruncateTableQuery implements the TruncateTableQuery interface.

func NewTruncateTableQuery

func NewTruncateTableQuery(db *BunDB) *BunTruncateTableQuery

NewTruncateTableQuery creates a new TruncateTableQuery.

func (*BunTruncateTableQuery) Cascade

func (*BunTruncateTableQuery) ContinueIdentity

func (q *BunTruncateTableQuery) ContinueIdentity() TruncateTableQuery

func (*BunTruncateTableQuery) Exec

func (q *BunTruncateTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunTruncateTableQuery) Model

func (*BunTruncateTableQuery) Restrict

func (*BunTruncateTableQuery) Table

func (q *BunTruncateTableQuery) Table(tables ...string) TruncateTableQuery

type BunTx

type BunTx struct {
	BunDB
}

BunTx wraps a bun.Tx to implement the Tx interface for manual transaction control.

func (*BunTx) Commit

func (t *BunTx) Commit() error

func (*BunTx) Rollback

func (t *BunTx) Rollback() error

type BunUpdateQuery

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

BunUpdateQuery is the concrete implementation of UpdateQuery interface. It wraps bun.UpdateQuery and provides additional functionality for expression building.

func NewUpdateQuery

func NewUpdateQuery(db *BunDB) *BunUpdateQuery

NewUpdateQuery creates a new UpdateQuery instance with the provided database instance. It initializes the query builders and sets up the table schema context for proper query building.

func (*BunUpdateQuery) Apply

func (q *BunUpdateQuery) Apply(fns ...ApplyFunc[UpdateQuery]) UpdateQuery

func (*BunUpdateQuery) ApplyIf

func (q *BunUpdateQuery) ApplyIf(condition bool, fns ...ApplyFunc[UpdateQuery]) UpdateQuery

func (*BunUpdateQuery) Bulk

func (q *BunUpdateQuery) Bulk() UpdateQuery

func (*BunUpdateQuery) Column

func (q *BunUpdateQuery) Column(name string, value any) UpdateQuery

func (*BunUpdateQuery) ColumnExpr

func (q *BunUpdateQuery) ColumnExpr(name string, builder func(ExprBuilder) any) UpdateQuery

func (*BunUpdateQuery) DB

func (q *BunUpdateQuery) DB() DB

func (*BunUpdateQuery) Exclude

func (q *BunUpdateQuery) Exclude(columns ...string) UpdateQuery

func (*BunUpdateQuery) ExcludeAll

func (q *BunUpdateQuery) ExcludeAll() UpdateQuery

func (*BunUpdateQuery) Exec

func (q *BunUpdateQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*BunUpdateQuery) IncludeDeleted

func (q *BunUpdateQuery) IncludeDeleted() UpdateQuery

func (*BunUpdateQuery) Limit

func (q *BunUpdateQuery) Limit(limit int) UpdateQuery

func (*BunUpdateQuery) Model

func (q *BunUpdateQuery) Model(model any) UpdateQuery

func (*BunUpdateQuery) ModelTable

func (q *BunUpdateQuery) ModelTable(name string, alias ...string) UpdateQuery

func (*BunUpdateQuery) OmitZero

func (q *BunUpdateQuery) OmitZero() UpdateQuery

func (*BunUpdateQuery) OrderBy

func (q *BunUpdateQuery) OrderBy(columns ...string) UpdateQuery

func (*BunUpdateQuery) OrderByDesc

func (q *BunUpdateQuery) OrderByDesc(columns ...string) UpdateQuery

func (*BunUpdateQuery) OrderByExpr

func (q *BunUpdateQuery) OrderByExpr(builder func(ExprBuilder) any) UpdateQuery

func (*BunUpdateQuery) Returning

func (q *BunUpdateQuery) Returning(columns ...string) UpdateQuery

func (*BunUpdateQuery) ReturningAll

func (q *BunUpdateQuery) ReturningAll() UpdateQuery

func (*BunUpdateQuery) ReturningNone

func (q *BunUpdateQuery) ReturningNone() UpdateQuery

func (*BunUpdateQuery) Scan

func (q *BunUpdateQuery) Scan(ctx context.Context, dest ...any) error

func (*BunUpdateQuery) Select

func (q *BunUpdateQuery) Select(columns ...string) UpdateQuery

func (*BunUpdateQuery) SelectAll

func (q *BunUpdateQuery) SelectAll() UpdateQuery

func (*BunUpdateQuery) Set

func (q *BunUpdateQuery) Set(name string, value any) UpdateQuery

func (*BunUpdateQuery) SetExpr

func (q *BunUpdateQuery) SetExpr(name string, builder func(ExprBuilder) any) UpdateQuery

func (*BunUpdateQuery) Table

func (q *BunUpdateQuery) Table(name string, alias ...string) UpdateQuery

func (*BunUpdateQuery) TableExpr

func (q *BunUpdateQuery) TableExpr(builder func(ExprBuilder) any, alias ...string) UpdateQuery

func (*BunUpdateQuery) TableFrom

func (q *BunUpdateQuery) TableFrom(model any, alias ...string) UpdateQuery

func (*BunUpdateQuery) TableSubQuery

func (q *BunUpdateQuery) TableSubQuery(builder func(SelectQuery), alias ...string) UpdateQuery

func (*BunUpdateQuery) Where

func (q *BunUpdateQuery) Where(builder func(ConditionBuilder)) UpdateQuery

func (*BunUpdateQuery) WhereDeleted

func (q *BunUpdateQuery) WhereDeleted() UpdateQuery

func (*BunUpdateQuery) WherePK

func (q *BunUpdateQuery) WherePK(columns ...string) UpdateQuery

func (*BunUpdateQuery) With

func (q *BunUpdateQuery) With(name string, builder func(SelectQuery)) UpdateQuery

func (*BunUpdateQuery) WithRecursive

func (q *BunUpdateQuery) WithRecursive(name string, builder func(SelectQuery)) UpdateQuery

func (*BunUpdateQuery) WithValues

func (q *BunUpdateQuery) WithValues(name string, model any, withOrder ...bool) UpdateQuery

type CTE

type CTE[T Executor] interface {
	// With adds a named CTE built from a SELECT subquery.
	With(name string, builder func(query SelectQuery)) T
	// WithValues adds a named CTE from a model's values (useful for bulk operations).
	WithValues(name string, model any, withOrder ...bool) T
	// WithRecursive adds a recursive CTE built from a SELECT subquery.
	WithRecursive(name string, builder func(query SelectQuery)) T
}

CTE defines methods for creating Common Table Expressions.

type CaseBuilder

type CaseBuilder interface {
	// Case adds a CASE expression.
	Case(expr any) CaseBuilder
	// CaseColumn adds a CASE expression with a column.
	CaseColumn(column string) CaseBuilder
	// CaseSubQuery adds a CASE expression with a subquery.
	CaseSubQuery(func(query SelectQuery)) CaseBuilder
	// When adds a WHEN condition for searched CASE.
	When(func(cb ConditionBuilder)) CaseWhenBuilder
	// WhenExpr adds a WHEN expression for searched CASE.
	WhenExpr(expr any) CaseWhenBuilder
	// WhenSubQuery adds a WHEN subquery for searched CASE.
	WhenSubQuery(func(query SelectQuery)) CaseWhenBuilder
	// Else sets the ELSE branch value for the CASE expression.
	Else(expr any)
	// ElseSubQuery adds a ELSE subquery for the CASE expression.
	ElseSubQuery(func(query SelectQuery))
}

CaseBuilder is an interface for building CASE expressions. Supports both searched CASE (WHEN condition) and simple CASE (WHEN value).

type CaseWhenBuilder

type CaseWhenBuilder interface {
	// Then sets the THEN result value for this WHEN clause.
	Then(expr any) CaseBuilder
	// ThenSubQuery sets the THEN result to a subquery for this WHEN clause.
	ThenSubQuery(func(query SelectQuery)) CaseBuilder
}

CaseWhenBuilder is an interface for building the THEN part of WHEN clauses.

type CheckBuilder

type CheckBuilder interface {
	// Name sets an explicit constraint name.
	// SQL: CONSTRAINT "name" CHECK (...)
	Name(name string) CheckBuilder
	// Condition sets the check condition using the ConditionBuilder.
	Condition(builder func(ConditionBuilder)) CheckBuilder
}

CheckBuilder provides a fluent API for defining table-level CHECK constraints.

type CheckDef

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

CheckDef holds the definition of a table-level check constraint.

func (*CheckDef) Condition

func (c *CheckDef) Condition(builder func(ConditionBuilder)) CheckBuilder

func (*CheckDef) Name

func (c *CheckDef) Name(name string) CheckBuilder

type ClauseConditionBuilder

type ClauseConditionBuilder struct {
	*CriteriaBuilder
	// contains filtered or unexported fields
}

ClauseConditionBuilder is responsible for collecting and grouping condition clauses, and rendering them.

func (*ClauseConditionBuilder) And

func (cb *ClauseConditionBuilder) And(query string, args ...any)

func (*ClauseConditionBuilder) AppendConditions

func (cb *ClauseConditionBuilder) AppendConditions(conditions ...schema.QueryWithSep)

func (*ClauseConditionBuilder) AppendGroup

func (cb *ClauseConditionBuilder) AppendGroup(sep string, conditions []schema.QueryWithSep)

func (*ClauseConditionBuilder) AppendQuery

func (cb *ClauseConditionBuilder) AppendQuery(gen schema.QueryGen, b []byte) (_ []byte, err error)

func (*ClauseConditionBuilder) BuildGroup

func (cb *ClauseConditionBuilder) BuildGroup(sep string, builder func(ConditionBuilder))

func (*ClauseConditionBuilder) Or

func (cb *ClauseConditionBuilder) Or(query string, args ...any)

type ColumnConstraint

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

ColumnConstraint represents a SQL column constraint such as NOT NULL, DEFAULT, PRIMARY KEY, etc.

func AutoIncrement

func AutoIncrement() ColumnConstraint

AutoIncrement creates an auto-increment column constraint. PostgreSQL: GENERATED BY DEFAULT AS IDENTITY, MySQL: AUTO_INCREMENT, SQLite: AUTOINCREMENT.

func Check

func Check(builder func(ConditionBuilder)) ColumnConstraint

Check creates a CHECK column constraint using the ConditionBuilder.

func Default

func Default(value any) ColumnConstraint

Default creates a DEFAULT column constraint with the given value.

func NotNull

func NotNull() ColumnConstraint

NotNull creates a NOT NULL column constraint.

func Nullable

func Nullable() ColumnConstraint

Nullable creates an explicit NULL column constraint.

func PrimaryKey

func PrimaryKey() ColumnConstraint

PrimaryKey creates a PRIMARY KEY column constraint.

func References

func References(table string, columns ...string) ColumnConstraint

References creates an inline foreign key column constraint.

func Unique

func Unique() ColumnConstraint

Unique creates a UNIQUE column constraint.

type ColumnHandler

type ColumnHandler interface {
	// Name returns the database column name this handler manages (e.g., "id", "created_at").
	Name() string
}

ColumnHandler provides the column name that the handler manages.

type ColumnInfo

type ColumnInfo struct {
	// Name is the column name in the database
	Name string
	// Alias is the custom alias for the column in the result set.
	// If empty and AutoAlias is false, the column uses its original name.
	Alias string
	// AutoAlias automatically generates an alias by prefixing the column name with the model name.
	// For example, if model is "User" and column is "name", the alias becomes "user_name".
	// This helps avoid column name conflicts when joining multiple tables.
	AutoAlias bool
}

ColumnInfo represents the configuration for selecting a column from a related model.

type ColumnUpdatable

type ColumnUpdatable[T Executor] interface {
	// Column sets a column to a literal value.
	Column(name string, value any) T
	// ColumnExpr sets a column to a SQL expression.
	ColumnExpr(name string, builder func(ExprBuilder) any) T
}

ColumnUpdatable defines methods for setting column values in queries.

type ConditionBuilder

type ConditionBuilder interface {
	Applier[ConditionBuilder]
	AuditConditionBuilder
	PKConditionBuilder
	// Equals is a condition that checks if a column is equal to a value.
	Equals(column string, value any) ConditionBuilder
	// OrEquals is a condition that checks if a column is equal to a value.
	OrEquals(column string, value any) ConditionBuilder
	// EqualsColumn is a condition that checks if a column is equal to another column.
	EqualsColumn(column1, column2 string) ConditionBuilder
	// OrEqualsColumn is a condition that checks if a column is equal to another column.
	OrEqualsColumn(column1, column2 string) ConditionBuilder
	// EqualsSubQuery is a condition that checks if a column is equal to a subquery.
	EqualsSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrEqualsSubQuery is a condition that checks if a column is equal to a subquery.
	OrEqualsSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// EqualsAny is a condition that checks if a column is equal to any value returned by a subquery.
	EqualsAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrEqualsAny is a condition that checks if a column is equal to any value returned by a subquery.
	OrEqualsAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// EqualsAll is a condition that checks if a column is equal to all values returned by a subquery.
	EqualsAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrEqualsAll is a condition that checks if a column is equal to all values returned by a subquery.
	OrEqualsAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// EqualsExpr is a condition that checks if a column is equal to an expression.
	EqualsExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// OrEqualsExpr is a condition that checks if a column is equal to an expression.
	OrEqualsExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// NotEquals is a condition that checks if a column is not equal to a value.
	NotEquals(column string, value any) ConditionBuilder
	// OrNotEquals is a condition that checks if a column is not equal to a value.
	OrNotEquals(column string, value any) ConditionBuilder
	// NotEqualsColumn is a condition that checks if a column is not equal to another column.
	NotEqualsColumn(column1, column2 string) ConditionBuilder
	// OrNotEqualsColumn is a condition that checks if a column is not equal to another column.
	OrNotEqualsColumn(column1, column2 string) ConditionBuilder
	// NotEqualsSubQuery is a condition that checks if a column is not equal to a subquery.
	NotEqualsSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrNotEqualsSubQuery is a condition that checks if a column is not equal to a subquery.
	OrNotEqualsSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// NotEqualsAny is a condition that checks if a column is not equal to any value returned by a subquery.
	NotEqualsAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrNotEqualsAny is a condition that checks if a column is not equal to any value returned by a subquery.
	OrNotEqualsAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// NotEqualsAll is a condition that checks if a column is not equal to all values returned by a subquery.
	NotEqualsAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrNotEqualsAll is a condition that checks if a column is not equal to all values returned by a subquery.
	OrNotEqualsAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// NotEqualsExpr is a condition that checks if a column is not equal to an expression.
	NotEqualsExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// OrNotEqualsExpr is a condition that checks if a column is not equal to an expression.
	OrNotEqualsExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// GreaterThan is a condition that checks if a column is greater than a value.
	GreaterThan(column string, value any) ConditionBuilder
	// OrGreaterThan is a condition that checks if a column is greater than a value.
	OrGreaterThan(column string, value any) ConditionBuilder
	// GreaterThanColumn is a condition that checks if a column is greater than another column.
	GreaterThanColumn(column1, column2 string) ConditionBuilder
	// OrGreaterThanColumn is a condition that checks if a column is greater than another column.
	OrGreaterThanColumn(column1, column2 string) ConditionBuilder
	// GreaterThanSubQuery is a condition that checks if a column is greater than a subquery.
	GreaterThanSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrGreaterThanSubQuery is a condition that checks if a column is greater than a subquery.
	OrGreaterThanSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// GreaterThanAny is a condition that checks if a column is greater than any value returned by a subquery.
	GreaterThanAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrGreaterThanAny is a condition that checks if a column is greater than any value returned by a subquery.
	OrGreaterThanAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// GreaterThanAll is a condition that checks if a column is greater than all values returned by a subquery.
	GreaterThanAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrGreaterThanAll is a condition that checks if a column is greater than all values returned by a subquery.
	OrGreaterThanAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// GreaterThanExpr is a condition that checks if a column is greater than an expression.
	GreaterThanExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// OrGreaterThanExpr is a condition that checks if a column is greater than an expression.
	OrGreaterThanExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// GreaterThanOrEqual is a condition that checks if a column is greater than or equal to a value.
	GreaterThanOrEqual(column string, value any) ConditionBuilder
	// OrGreaterThanOrEqual is a condition that checks if a column is greater than or equal to a value.
	OrGreaterThanOrEqual(column string, value any) ConditionBuilder
	// GreaterThanOrEqualColumn is a condition that checks if a column is greater than or equal to another column.
	GreaterThanOrEqualColumn(column1, column2 string) ConditionBuilder
	// OrGreaterThanOrEqualColumn is a condition that checks if a column is greater than or equal to another column.
	OrGreaterThanOrEqualColumn(column1, column2 string) ConditionBuilder
	// GreaterThanOrEqualSubQuery is a condition that checks if a column is greater than or equal to a subquery.
	GreaterThanOrEqualSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrGreaterThanOrEqualSubQuery is a condition that checks if a column is greater than or equal to a subquery.
	OrGreaterThanOrEqualSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// GreaterThanOrEqualAny is a condition that checks if a column is greater than or equal to any value returned by a subquery.
	GreaterThanOrEqualAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrGreaterThanOrEqualAny is a condition that checks if a column is greater than or equal to any value returned by a subquery.
	OrGreaterThanOrEqualAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// GreaterThanOrEqualAll is a condition that checks if a column is greater than or equal to all values returned by a subquery.
	GreaterThanOrEqualAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrGreaterThanOrEqualAll is a condition that checks if a column is greater than or equal to all values returned by a subquery.
	OrGreaterThanOrEqualAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// GreaterThanOrEqualExpr is a condition that checks if a column is greater than or equal to an expression.
	GreaterThanOrEqualExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// OrGreaterThanOrEqualExpr is a condition that checks if a column is greater than or equal to an expression.
	OrGreaterThanOrEqualExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// LessThan is a condition that checks if a column is less than a value.
	LessThan(column string, value any) ConditionBuilder
	// OrLessThan is a condition that checks if a column is less than a value.
	OrLessThan(column string, value any) ConditionBuilder
	// LessThanColumn is a condition that checks if a column is less than another column.
	LessThanColumn(column1, column2 string) ConditionBuilder
	// OrLessThanColumn is a condition that checks if a column is less than another column.
	OrLessThanColumn(column1, column2 string) ConditionBuilder
	// LessThanSubQuery is a condition that checks if a column is less than a subquery.
	LessThanSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrLessThanSubQuery is a condition that checks if a column is less than a subquery.
	OrLessThanSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// LessThanAny is a condition that checks if a column is less than any value returned by a subquery.
	LessThanAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrLessThanAny is a condition that checks if a column is less than any value returned by a subquery.
	OrLessThanAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// LessThanAll is a condition that checks if a column is less than all values returned by a subquery.
	LessThanAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrLessThanAll is a condition that checks if a column is less than all values returned by a subquery.
	OrLessThanAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// LessThanExpr is a condition that checks if a column is less than an expression.
	LessThanExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// OrLessThanExpr is a condition that checks if a column is less than an expression.
	OrLessThanExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// LessThanOrEqual is a condition that checks if a column is less than or equal to a value.
	LessThanOrEqual(column string, value any) ConditionBuilder
	// OrLessThanOrEqual is a condition that checks if a column is less than or equal to a value.
	OrLessThanOrEqual(column string, value any) ConditionBuilder
	// LessThanOrEqualColumn is a condition that checks if a column is less than or equal to another column.
	LessThanOrEqualColumn(column1, column2 string) ConditionBuilder
	// OrLessThanOrEqualColumn is a condition that checks if a column is less than or equal to another column.
	OrLessThanOrEqualColumn(column1, column2 string) ConditionBuilder
	// LessThanOrEqualSubQuery is a condition that checks if a column is less than or equal to a subquery.
	LessThanOrEqualSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrLessThanOrEqualSubQuery is a condition that checks if a column is less than or equal to a subquery.
	OrLessThanOrEqualSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// LessThanOrEqualAny is a condition that checks if a column is less than or equal to any value returned by a subquery.
	LessThanOrEqualAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrLessThanOrEqualAny is a condition that checks if a column is less than or equal to any value returned by a subquery.
	OrLessThanOrEqualAny(column string, builder func(query SelectQuery)) ConditionBuilder
	// LessThanOrEqualAll is a condition that checks if a column is less than or equal to all values returned by a subquery.
	LessThanOrEqualAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrLessThanOrEqualAll is a condition that checks if a column is less than or equal to all values returned by a subquery.
	OrLessThanOrEqualAll(column string, builder func(query SelectQuery)) ConditionBuilder
	// LessThanOrEqualExpr is a condition that checks if a column is less than or equal to an expression.
	LessThanOrEqualExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// OrLessThanOrEqualExpr is a condition that checks if a column is less than or equal to an expression.
	OrLessThanOrEqualExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// Between is a condition that checks if a column is between two values.
	Between(column string, start, end any) ConditionBuilder
	// OrBetween is a condition that checks if a column is between two values.
	OrBetween(column string, start, end any) ConditionBuilder
	// BetweenExpr is a condition that checks if a column is between an expression and a value.
	BetweenExpr(column string, startB, endB func(ExprBuilder) any) ConditionBuilder
	// OrBetweenExpr is a condition that checks if a column is between an expression and a value.
	OrBetweenExpr(column string, startB, endB func(ExprBuilder) any) ConditionBuilder
	// NotBetween is a condition that checks if a column is not between two values.
	NotBetween(column string, start, end any) ConditionBuilder
	// OrNotBetween is a condition that checks if a column is not between two values.
	OrNotBetween(column string, start, end any) ConditionBuilder
	// NotBetweenExpr is a condition that checks if a column is not between an expression and a value.
	NotBetweenExpr(column string, startB, endB func(ExprBuilder) any) ConditionBuilder
	// OrNotBetweenExpr is a condition that checks if a column is not between an expression and a value.
	OrNotBetweenExpr(column string, startB, endB func(ExprBuilder) any) ConditionBuilder
	// In is a condition that checks if a column is in a list of values.
	In(column string, values any) ConditionBuilder
	// OrIn is a condition that checks if a column is in a list of values.
	OrIn(column string, values any) ConditionBuilder
	// InSubQuery is a condition that checks if a column is in a subquery.
	InSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrInSubQuery is a condition that checks if a column is in a subquery.
	OrInSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// InExpr is a condition that checks if a column is in an expression.
	InExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// OrInExpr is a condition that checks if a column is in an expression.
	OrInExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// NotIn is a condition that checks if a column is not in a list of values.
	NotIn(column string, values any) ConditionBuilder
	// OrNotIn is a condition that checks if a column is not in a list of values.
	OrNotIn(column string, values any) ConditionBuilder
	// NotInSubQuery is a condition that checks if a column is not in a subquery.
	NotInSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// OrNotInSubQuery is a condition that checks if a column is not in a subquery.
	OrNotInSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder
	// NotInExpr is a condition that checks if a column is not in an expression.
	NotInExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// OrNotInExpr is a condition that checks if a column is not in an expression.
	OrNotInExpr(column string, builder func(ExprBuilder) any) ConditionBuilder
	// IsNull is a condition that checks if a column is null.
	IsNull(column string) ConditionBuilder
	// OrIsNull is a condition that checks if a column is null.
	OrIsNull(column string) ConditionBuilder
	// IsNullSubQuery is a condition that checks if a column is null.
	IsNullSubQuery(builder func(query SelectQuery)) ConditionBuilder
	// OrIsNullSubQuery is a condition that checks if a column is null.
	OrIsNullSubQuery(builder func(query SelectQuery)) ConditionBuilder
	// IsNullExpr is a condition that checks if a column is null.
	IsNullExpr(builder func(ExprBuilder) any) ConditionBuilder
	// OrIsNullExpr is a condition that checks if a column is null.
	OrIsNullExpr(builder func(ExprBuilder) any) ConditionBuilder
	// IsNotNull is a condition that checks if a column is not null.
	IsNotNull(column string) ConditionBuilder
	// OrIsNotNull is a condition that checks if a column is not null.
	OrIsNotNull(column string) ConditionBuilder
	// IsNotNullSubQuery is a condition that checks if a column is not null.
	IsNotNullSubQuery(builder func(query SelectQuery)) ConditionBuilder
	// OrIsNotNullSubQuery is a condition that checks if a column is not null.
	OrIsNotNullSubQuery(builder func(query SelectQuery)) ConditionBuilder
	// IsNotNullExpr is a condition that checks if a column is not null.
	IsNotNullExpr(builder func(ExprBuilder) any) ConditionBuilder
	// OrIsNotNullExpr is a condition that checks if a column is not null.
	OrIsNotNullExpr(builder func(ExprBuilder) any) ConditionBuilder
	// IsTrue is a condition that checks if a column is true.
	IsTrue(column string) ConditionBuilder
	// OrIsTrue is a condition that checks if a column is true.
	OrIsTrue(column string) ConditionBuilder
	// IsTrueSubQuery is a condition that checks if a column is true.
	IsTrueSubQuery(builder func(query SelectQuery)) ConditionBuilder
	// OrIsTrueSubQuery is a condition that checks if a column is true.
	OrIsTrueSubQuery(builder func(query SelectQuery)) ConditionBuilder
	// IsTrueExpr is a condition that checks if a column is true.
	IsTrueExpr(builder func(ExprBuilder) any) ConditionBuilder
	// OrIsTrueExpr is a condition that checks if a column is true.
	OrIsTrueExpr(builder func(ExprBuilder) any) ConditionBuilder
	// IsFalse is a condition that checks if a column is false.
	IsFalse(column string) ConditionBuilder
	// OrIsFalse is a condition that checks if a column is false.
	OrIsFalse(column string) ConditionBuilder
	// IsFalseSubQuery is a condition that checks if a column is false.
	IsFalseSubQuery(builder func(query SelectQuery)) ConditionBuilder
	// OrIsFalseSubQuery is a condition that checks if a column is false.
	OrIsFalseSubQuery(builder func(query SelectQuery)) ConditionBuilder
	// IsFalseExpr is a condition that checks if a column is false.
	IsFalseExpr(builder func(ExprBuilder) any) ConditionBuilder
	// OrIsFalseExpr is a condition that checks if a column is false.
	OrIsFalseExpr(builder func(ExprBuilder) any) ConditionBuilder
	// Contains is a condition that checks if a column contains a value.
	Contains(column, value string) ConditionBuilder
	// OrContains is a condition that checks if a column contains a value.
	OrContains(column, value string) ConditionBuilder
	// ContainsAny is a condition that checks if a column contains any of the values.
	ContainsAny(column string, values []string) ConditionBuilder
	// OrContainsAny is a condition that checks if a column contains any of the values.
	OrContainsAny(column string, values []string) ConditionBuilder
	// ContainsIgnoreCase is a condition that checks if a column contains a value, ignoring case.
	ContainsIgnoreCase(column, value string) ConditionBuilder
	// OrContainsIgnoreCase is a condition that checks if a column contains a value, ignoring case.
	OrContainsIgnoreCase(column, value string) ConditionBuilder
	// ContainsAnyIgnoreCase is a condition that checks if a column contains any of the values, ignoring case.
	ContainsAnyIgnoreCase(column string, values []string) ConditionBuilder
	// OrContainsAnyIgnoreCase is a condition that checks if a column contains any of the values, ignoring case.
	OrContainsAnyIgnoreCase(column string, values []string) ConditionBuilder
	// NotContains is a condition that checks if a column does not contain a value.
	NotContains(column, value string) ConditionBuilder
	// OrNotContains is a condition that checks if a column does not contain a value.
	OrNotContains(column, value string) ConditionBuilder
	// NotContainsAny is a condition that checks if a column does not contain any of the values.
	NotContainsAny(column string, values []string) ConditionBuilder
	// OrNotContainsAny is a condition that checks if a column does not contain any of the values.
	OrNotContainsAny(column string, values []string) ConditionBuilder
	// NotContainsIgnoreCase is a condition that checks if a column does not contain a value, ignoring case.
	NotContainsIgnoreCase(column, value string) ConditionBuilder
	// OrNotContainsIgnoreCase is a condition that checks if a column does not contain a value, ignoring case.
	OrNotContainsIgnoreCase(column, value string) ConditionBuilder
	// NotContainsAnyIgnoreCase is a condition that checks if a column does not contain any of the values, ignoring case.
	NotContainsAnyIgnoreCase(column string, values []string) ConditionBuilder
	// OrNotContainsAnyIgnoreCase is a condition that checks if a column does not contain any of the values, ignoring case.
	OrNotContainsAnyIgnoreCase(column string, values []string) ConditionBuilder
	// StartsWith is a condition that checks if a column starts with a value.
	StartsWith(column, value string) ConditionBuilder
	// OrStartsWith is a condition that checks if a column starts with a value.
	OrStartsWith(column, value string) ConditionBuilder
	// StartsWithAny is a condition that checks if a column starts with any of the values.
	StartsWithAny(column string, values []string) ConditionBuilder
	// OrStartsWithAny is a condition that checks if a column starts with any of the values.
	OrStartsWithAny(column string, values []string) ConditionBuilder
	// StartsWithIgnoreCase is a condition that checks if a column starts with a value, ignoring case.
	StartsWithIgnoreCase(column, value string) ConditionBuilder
	// OrStartsWithIgnoreCase is a condition that checks if a column starts with a value, ignoring case.
	OrStartsWithIgnoreCase(column, value string) ConditionBuilder
	// StartsWithAnyIgnoreCase is a condition that checks if a column starts with any of the values, ignoring case.
	StartsWithAnyIgnoreCase(column string, values []string) ConditionBuilder
	// OrStartsWithAnyIgnoreCase is a condition that checks if a column starts with any of the values, ignoring case.
	OrStartsWithAnyIgnoreCase(column string, values []string) ConditionBuilder
	// NotStartsWith is a condition that checks if a column does not start with a value.
	NotStartsWith(column, value string) ConditionBuilder
	// OrNotStartsWith is a condition that checks if a column does not start with a value.
	OrNotStartsWith(column, value string) ConditionBuilder
	// NotStartsWithAny is a condition that checks if a column does not start with any of the values.
	NotStartsWithAny(column string, values []string) ConditionBuilder
	// OrNotStartsWithAny is a condition that checks if a column does not start with any of the values.
	OrNotStartsWithAny(column string, values []string) ConditionBuilder
	// NotStartsWithIgnoreCase is a condition that checks if a column does not start with a value, ignoring case.
	NotStartsWithIgnoreCase(column, value string) ConditionBuilder
	// OrNotStartsWithIgnoreCase is a condition that checks if a column does not start with a value, ignoring case.
	OrNotStartsWithIgnoreCase(column, value string) ConditionBuilder
	// NotStartsWithAnyIgnoreCase is a condition that checks if a column does not start with any of the values, ignoring case.
	NotStartsWithAnyIgnoreCase(column string, values []string) ConditionBuilder
	// OrNotStartsWithAnyIgnoreCase is a condition that checks if a column does not start with any of the values, ignoring case.
	OrNotStartsWithAnyIgnoreCase(column string, values []string) ConditionBuilder
	// EndsWith is a condition that checks if a column ends with a value.
	EndsWith(column, value string) ConditionBuilder
	// OrEndsWith is a condition that checks if a column ends with a value.
	OrEndsWith(column, value string) ConditionBuilder
	// EndsWithAny is a condition that checks if a column ends with any of the values.
	EndsWithAny(column string, values []string) ConditionBuilder
	// OrEndsWithAny is a condition that checks if a column ends with any of the values.
	OrEndsWithAny(column string, values []string) ConditionBuilder
	// EndsWithIgnoreCase is a condition that checks if a column ends with a value, ignoring case.
	EndsWithIgnoreCase(column, value string) ConditionBuilder
	// OrEndsWithIgnoreCase is a condition that checks if a column ends with a value, ignoring case.
	OrEndsWithIgnoreCase(column, value string) ConditionBuilder
	// EndsWithAnyIgnoreCase is a condition that checks if a column ends with any of the values, ignoring case.
	EndsWithAnyIgnoreCase(column string, values []string) ConditionBuilder
	// OrEndsWithAnyIgnoreCase is a condition that checks if a column ends with any of the values, ignoring case.
	OrEndsWithAnyIgnoreCase(column string, values []string) ConditionBuilder
	// NotEndsWith is a condition that checks if a column does not end with a value.
	NotEndsWith(column, value string) ConditionBuilder
	// OrNotEndsWith is a condition that checks if a column does not end with a value.
	OrNotEndsWith(column, value string) ConditionBuilder
	// NotEndsWithAny is a condition that checks if a column does not end with any of the values.
	NotEndsWithAny(column string, values []string) ConditionBuilder
	// OrNotEndsWithAny is a condition that checks if a column does not end with any of the values.
	OrNotEndsWithAny(column string, values []string) ConditionBuilder
	// NotEndsWithIgnoreCase is a condition that checks if a column does not end with a value, ignoring case.
	NotEndsWithIgnoreCase(column, value string) ConditionBuilder
	// OrNotEndsWithIgnoreCase is a condition that checks if a column does not end with a value, ignoring case.
	OrNotEndsWithIgnoreCase(column, value string) ConditionBuilder
	// NotEndsWithAnyIgnoreCase is a condition that checks if a column does not end with any of the values, ignoring case.
	NotEndsWithAnyIgnoreCase(column string, values []string) ConditionBuilder
	// OrNotEndsWithAnyIgnoreCase is a condition that checks if a column does not end with any of the values, ignoring case.
	OrNotEndsWithAnyIgnoreCase(column string, values []string) ConditionBuilder
	// Expr is a condition that checks if an expression is true.
	Expr(builder func(ExprBuilder) any) ConditionBuilder
	// OrExpr is a condition that checks if an expression is true.
	OrExpr(builder func(ExprBuilder) any) ConditionBuilder
	// Group is a condition that checks if a group of conditions are true.
	Group(builder func(ConditionBuilder)) ConditionBuilder
	// OrGroup is a condition that checks if a group of conditions are true.
	OrGroup(builder func(ConditionBuilder)) ConditionBuilder
}

ConditionBuilder is a builder for conditions.

type ConflictAction

type ConflictAction int

ConflictAction represents the action strategy for INSERT ... ON CONFLICT.

const (
	ConflictDoNothing ConflictAction = iota
	ConflictDoUpdate
)

func (ConflictAction) String

func (c ConflictAction) String() string

type ConflictBuilder

type ConflictBuilder interface {
	// Columns specifies the conflict target columns (used with DO UPDATE).
	Columns(columns ...string) ConflictBuilder
	// Constraint specifies a named constraint as the conflict target.
	Constraint(name string) ConflictBuilder
	// Where adds a condition to the conflict target (partial unique index filter).
	Where(func(ConditionBuilder)) ConflictBuilder

	// DoNothing performs DO NOTHING on conflict and finalizes the conflict handling.
	DoNothing()
	// DoUpdate performs DO UPDATE on conflict and returns a builder for update operations.
	DoUpdate() ConflictUpdateBuilder
}

ConflictBuilder is used to configure INSERT conflict handling (UPSERT) target in a dialect-aware way. This is the first stage that defines the conflict target (columns, constraints, conditions).

type ConflictUpdateBuilder

type ConflictUpdateBuilder interface {
	// Set adds an assignment in DO UPDATE clause. If no value provided, uses excluded/VALUES value when supported.
	Set(column string, value ...any) ConflictUpdateBuilder
	// SetExpr adds an expression assignment in DO UPDATE clause.
	SetExpr(column string, builder func(ExprBuilder) any) ConflictUpdateBuilder
	// Where adds a predicate to DO UPDATE (PostgreSQL/SQLite). Ignored on MySQL.
	Where(func(ConditionBuilder)) ConflictUpdateBuilder
}

ConflictUpdateBuilder is used to configure the UPDATE part of conflict handling. This is the second stage that defines what to update when conflicts occur.

type ConstraintKind

type ConstraintKind int

ConstraintKind identifies the type of column constraint.

const (
	ConstraintNotNull ConstraintKind = iota
	ConstraintNullable
	ConstraintDefault
	ConstraintPrimaryKey
	ConstraintUnique
	ConstraintAutoIncrement
	ConstraintCheck
	ConstraintReferences
)

type CountBuilder

type CountBuilder interface {
	BaseAggregate[CountBuilder]
	DistinctableAggregate[CountBuilder]
	// All configures COUNT(*) semantics.
	All() CountBuilder
}

CountBuilder defines the COUNT aggregate function builder.

type CreateIndexQuery

type CreateIndexQuery interface {
	Executor
	TableTarget[CreateIndexQuery]

	// Index sets the index name.
	Index(name string) CreateIndexQuery
	// Column specifies the columns to include in the index.
	Column(columns ...string) CreateIndexQuery
	// ColumnExpr adds an expression-based index column (e.g., for functional indexes).
	ColumnExpr(builder func(ExprBuilder) any) CreateIndexQuery
	// ExcludeColumn removes columns from the model's default index column set.
	ExcludeColumn(columns ...string) CreateIndexQuery
	// Unique creates a unique index that enforces uniqueness on the indexed columns.
	Unique() CreateIndexQuery
	// Concurrently creates the index concurrently (PostgreSQL only).
	Concurrently() CreateIndexQuery
	// IfNotExists skips creation when the index already exists.
	IfNotExists() CreateIndexQuery
	// Include adds covering columns (PostgreSQL INCLUDE clause).
	Include(columns ...string) CreateIndexQuery
	// Using sets the index method (e.g., BTREE, HASH, GIN, GiST).
	Using(method IndexMethod) CreateIndexQuery
	// Where adds a partial index condition to only index rows matching the condition.
	Where(builder func(ConditionBuilder)) CreateIndexQuery
}

CreateIndexQuery builds and executes CREATE INDEX queries.

type CreateTableQuery

type CreateTableQuery interface {
	Executor
	TableTarget[CreateTableQuery]
	fmt.Stringer

	// Column adds a column definition with data type and optional constraints.
	Column(name string, dataType DataTypeDef, constraints ...ColumnConstraint) CreateTableQuery
	// Temp creates a temporary table that is dropped at the end of the session.
	Temp() CreateTableQuery
	// IfNotExists adds IF NOT EXISTS to skip creation when the table already exists.
	IfNotExists() CreateTableQuery
	// DefaultVarChar sets the default VARCHAR length for string columns in model-based creation.
	DefaultVarChar(n int) CreateTableQuery
	// PrimaryKey adds a composite primary key constraint using the builder DSL.
	PrimaryKey(builder func(PrimaryKeyBuilder)) CreateTableQuery
	// Unique adds a unique constraint using the builder DSL.
	Unique(builder func(UniqueBuilder)) CreateTableQuery
	// Check adds a check constraint using the builder DSL.
	Check(builder func(CheckBuilder)) CreateTableQuery
	// ForeignKey adds a foreign key constraint using the builder DSL.
	ForeignKey(builder func(ForeignKeyBuilder)) CreateTableQuery
	// PartitionBy configures table partitioning with the given strategy and columns.
	PartitionBy(strategy PartitionStrategy, columns ...string) CreateTableQuery
	// TableSpace assigns the table to a specific tablespace for storage management.
	TableSpace(tablespace string) CreateTableQuery
	// WithForeignKeys creates foreign keys from model relations.
	WithForeignKeys() CreateTableQuery
}

CreateTableQuery builds and executes CREATE TABLE queries.

type CreatedAtHandler

type CreatedAtHandler struct{}

CreatedAtHandler sets created_at timestamps on insert.

func (*CreatedAtHandler) Name

func (*CreatedAtHandler) Name() string

func (*CreatedAtHandler) OnInsert

func (*CreatedAtHandler) OnInsert(_ *BunInsertQuery, _ *schema.Table, _ *schema.Field, _ any, value reflect.Value)

type CreatedByHandler

type CreatedByHandler struct{}

CreatedByHandler sets created_by using the current operator on insert.

func (*CreatedByHandler) Name

func (*CreatedByHandler) Name() string

func (*CreatedByHandler) OnInsert

func (cb *CreatedByHandler) OnInsert(query *BunInsertQuery, _ *schema.Table, _ *schema.Field, _ any, value reflect.Value)

type CreatedModel

type CreatedModel struct {
	CreatedAt     timex.DateTime `json:"createdAt" bun:",notnull,type:timestamp,default:CURRENT_TIMESTAMP,skipupdate"`
	CreatedBy     string         `json:"createdBy" bun:",notnull,skipupdate" mold:"translate=user?"`
	CreatedByName string         `json:"createdByName" bun:",scanonly"`
}

CreatedModel contains creation tracking fields.

type CriteriaBuilder

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

func (*CriteriaBuilder) Apply

func (*CriteriaBuilder) ApplyIf

func (cb *CriteriaBuilder) ApplyIf(condition bool, fns ...ApplyFunc[ConditionBuilder]) ConditionBuilder

func (*CriteriaBuilder) Between

func (cb *CriteriaBuilder) Between(column string, start, end any) ConditionBuilder

func (*CriteriaBuilder) BetweenExpr

func (cb *CriteriaBuilder) BetweenExpr(column string, startB, endB func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) Contains

func (cb *CriteriaBuilder) Contains(column, value string) ConditionBuilder

func (*CriteriaBuilder) ContainsAny

func (cb *CriteriaBuilder) ContainsAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) ContainsAnyIgnoreCase

func (cb *CriteriaBuilder) ContainsAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) ContainsIgnoreCase

func (cb *CriteriaBuilder) ContainsIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) CreatedAtBetween

func (cb *CriteriaBuilder) CreatedAtBetween(start, end time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedAtGreaterThan

func (cb *CriteriaBuilder) CreatedAtGreaterThan(createdAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedAtGreaterThanOrEqual

func (cb *CriteriaBuilder) CreatedAtGreaterThanOrEqual(createdAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedAtLessThan

func (cb *CriteriaBuilder) CreatedAtLessThan(createdAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedAtLessThanOrEqual

func (cb *CriteriaBuilder) CreatedAtLessThanOrEqual(createdAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedAtNotBetween

func (cb *CriteriaBuilder) CreatedAtNotBetween(start, end time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByEquals

func (cb *CriteriaBuilder) CreatedByEquals(createdBy string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByEqualsAll

func (cb *CriteriaBuilder) CreatedByEqualsAll(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByEqualsAny

func (cb *CriteriaBuilder) CreatedByEqualsAny(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByEqualsCurrent

func (cb *CriteriaBuilder) CreatedByEqualsCurrent(alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByEqualsSubQuery

func (cb *CriteriaBuilder) CreatedByEqualsSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByIn

func (cb *CriteriaBuilder) CreatedByIn(createdBys []string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByInSubQuery

func (cb *CriteriaBuilder) CreatedByInSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByNotEquals

func (cb *CriteriaBuilder) CreatedByNotEquals(createdBy string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByNotEqualsAll

func (cb *CriteriaBuilder) CreatedByNotEqualsAll(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByNotEqualsAny

func (cb *CriteriaBuilder) CreatedByNotEqualsAny(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByNotEqualsCurrent

func (cb *CriteriaBuilder) CreatedByNotEqualsCurrent(alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByNotEqualsSubQuery

func (cb *CriteriaBuilder) CreatedByNotEqualsSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByNotIn

func (cb *CriteriaBuilder) CreatedByNotIn(createdBys []string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) CreatedByNotInSubQuery

func (cb *CriteriaBuilder) CreatedByNotInSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) EndsWith

func (cb *CriteriaBuilder) EndsWith(column, value string) ConditionBuilder

func (*CriteriaBuilder) EndsWithAny

func (cb *CriteriaBuilder) EndsWithAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) EndsWithAnyIgnoreCase

func (cb *CriteriaBuilder) EndsWithAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) EndsWithIgnoreCase

func (cb *CriteriaBuilder) EndsWithIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) Equals

func (cb *CriteriaBuilder) Equals(column string, value any) ConditionBuilder

func (*CriteriaBuilder) EqualsAll

func (cb *CriteriaBuilder) EqualsAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) EqualsAny

func (cb *CriteriaBuilder) EqualsAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) EqualsColumn

func (cb *CriteriaBuilder) EqualsColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) EqualsExpr

func (cb *CriteriaBuilder) EqualsExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) EqualsSubQuery

func (cb *CriteriaBuilder) EqualsSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) Expr

func (cb *CriteriaBuilder) Expr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) GreaterThan

func (cb *CriteriaBuilder) GreaterThan(column string, value any) ConditionBuilder

func (*CriteriaBuilder) GreaterThanAll

func (cb *CriteriaBuilder) GreaterThanAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) GreaterThanAny

func (cb *CriteriaBuilder) GreaterThanAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) GreaterThanColumn

func (cb *CriteriaBuilder) GreaterThanColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) GreaterThanExpr

func (cb *CriteriaBuilder) GreaterThanExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) GreaterThanOrEqual

func (cb *CriteriaBuilder) GreaterThanOrEqual(column string, value any) ConditionBuilder

func (*CriteriaBuilder) GreaterThanOrEqualAll

func (cb *CriteriaBuilder) GreaterThanOrEqualAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) GreaterThanOrEqualAny

func (cb *CriteriaBuilder) GreaterThanOrEqualAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) GreaterThanOrEqualColumn

func (cb *CriteriaBuilder) GreaterThanOrEqualColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) GreaterThanOrEqualExpr

func (cb *CriteriaBuilder) GreaterThanOrEqualExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) GreaterThanOrEqualSubQuery

func (cb *CriteriaBuilder) GreaterThanOrEqualSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) GreaterThanSubQuery

func (cb *CriteriaBuilder) GreaterThanSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) Group

func (cb *CriteriaBuilder) Group(builder func(ConditionBuilder)) ConditionBuilder

func (*CriteriaBuilder) In

func (cb *CriteriaBuilder) In(column string, values any) ConditionBuilder

func (*CriteriaBuilder) InExpr

func (cb *CriteriaBuilder) InExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) InSubQuery

func (cb *CriteriaBuilder) InSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) IsFalse

func (cb *CriteriaBuilder) IsFalse(column string) ConditionBuilder

func (*CriteriaBuilder) IsFalseExpr

func (cb *CriteriaBuilder) IsFalseExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) IsFalseSubQuery

func (cb *CriteriaBuilder) IsFalseSubQuery(builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) IsNotNull

func (cb *CriteriaBuilder) IsNotNull(column string) ConditionBuilder

func (*CriteriaBuilder) IsNotNullExpr

func (cb *CriteriaBuilder) IsNotNullExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) IsNotNullSubQuery

func (cb *CriteriaBuilder) IsNotNullSubQuery(builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) IsNull

func (cb *CriteriaBuilder) IsNull(column string) ConditionBuilder

func (*CriteriaBuilder) IsNullExpr

func (cb *CriteriaBuilder) IsNullExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) IsNullSubQuery

func (cb *CriteriaBuilder) IsNullSubQuery(builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) IsTrue

func (cb *CriteriaBuilder) IsTrue(column string) ConditionBuilder

func (*CriteriaBuilder) IsTrueExpr

func (cb *CriteriaBuilder) IsTrueExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) IsTrueSubQuery

func (cb *CriteriaBuilder) IsTrueSubQuery(builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) LessThan

func (cb *CriteriaBuilder) LessThan(column string, value any) ConditionBuilder

func (*CriteriaBuilder) LessThanAll

func (cb *CriteriaBuilder) LessThanAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) LessThanAny

func (cb *CriteriaBuilder) LessThanAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) LessThanColumn

func (cb *CriteriaBuilder) LessThanColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) LessThanExpr

func (cb *CriteriaBuilder) LessThanExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) LessThanOrEqual

func (cb *CriteriaBuilder) LessThanOrEqual(column string, value any) ConditionBuilder

func (*CriteriaBuilder) LessThanOrEqualAll

func (cb *CriteriaBuilder) LessThanOrEqualAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) LessThanOrEqualAny

func (cb *CriteriaBuilder) LessThanOrEqualAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) LessThanOrEqualColumn

func (cb *CriteriaBuilder) LessThanOrEqualColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) LessThanOrEqualExpr

func (cb *CriteriaBuilder) LessThanOrEqualExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) LessThanOrEqualSubQuery

func (cb *CriteriaBuilder) LessThanOrEqualSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) LessThanSubQuery

func (cb *CriteriaBuilder) LessThanSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) NotBetween

func (cb *CriteriaBuilder) NotBetween(column string, start, end any) ConditionBuilder

func (*CriteriaBuilder) NotBetweenExpr

func (cb *CriteriaBuilder) NotBetweenExpr(column string, startB, endB func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) NotContains

func (cb *CriteriaBuilder) NotContains(column, value string) ConditionBuilder

func (*CriteriaBuilder) NotContainsAny

func (cb *CriteriaBuilder) NotContainsAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) NotContainsAnyIgnoreCase

func (cb *CriteriaBuilder) NotContainsAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) NotContainsIgnoreCase

func (cb *CriteriaBuilder) NotContainsIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) NotEndsWith

func (cb *CriteriaBuilder) NotEndsWith(column, value string) ConditionBuilder

func (*CriteriaBuilder) NotEndsWithAny

func (cb *CriteriaBuilder) NotEndsWithAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) NotEndsWithAnyIgnoreCase

func (cb *CriteriaBuilder) NotEndsWithAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) NotEndsWithIgnoreCase

func (cb *CriteriaBuilder) NotEndsWithIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) NotEquals

func (cb *CriteriaBuilder) NotEquals(column string, value any) ConditionBuilder

func (*CriteriaBuilder) NotEqualsAll

func (cb *CriteriaBuilder) NotEqualsAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) NotEqualsAny

func (cb *CriteriaBuilder) NotEqualsAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) NotEqualsColumn

func (cb *CriteriaBuilder) NotEqualsColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) NotEqualsExpr

func (cb *CriteriaBuilder) NotEqualsExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) NotEqualsSubQuery

func (cb *CriteriaBuilder) NotEqualsSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) NotIn

func (cb *CriteriaBuilder) NotIn(column string, values any) ConditionBuilder

func (*CriteriaBuilder) NotInExpr

func (cb *CriteriaBuilder) NotInExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) NotInSubQuery

func (cb *CriteriaBuilder) NotInSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) NotStartsWith

func (cb *CriteriaBuilder) NotStartsWith(column, value string) ConditionBuilder

func (*CriteriaBuilder) NotStartsWithAny

func (cb *CriteriaBuilder) NotStartsWithAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) NotStartsWithAnyIgnoreCase

func (cb *CriteriaBuilder) NotStartsWithAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) NotStartsWithIgnoreCase

func (cb *CriteriaBuilder) NotStartsWithIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrBetween

func (cb *CriteriaBuilder) OrBetween(column string, start, end any) ConditionBuilder

func (*CriteriaBuilder) OrBetweenExpr

func (cb *CriteriaBuilder) OrBetweenExpr(column string, startB, endB func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrContains

func (cb *CriteriaBuilder) OrContains(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrContainsAny

func (cb *CriteriaBuilder) OrContainsAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrContainsAnyIgnoreCase

func (cb *CriteriaBuilder) OrContainsAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrContainsIgnoreCase

func (cb *CriteriaBuilder) OrContainsIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedAtBetween

func (cb *CriteriaBuilder) OrCreatedAtBetween(start, end time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedAtGreaterThan

func (cb *CriteriaBuilder) OrCreatedAtGreaterThan(createdAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedAtGreaterThanOrEqual

func (cb *CriteriaBuilder) OrCreatedAtGreaterThanOrEqual(createdAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedAtLessThan

func (cb *CriteriaBuilder) OrCreatedAtLessThan(createdAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedAtLessThanOrEqual

func (cb *CriteriaBuilder) OrCreatedAtLessThanOrEqual(createdAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedAtNotBetween

func (cb *CriteriaBuilder) OrCreatedAtNotBetween(start, end time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByEquals

func (cb *CriteriaBuilder) OrCreatedByEquals(createdBy string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByEqualsAll

func (cb *CriteriaBuilder) OrCreatedByEqualsAll(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByEqualsAny

func (cb *CriteriaBuilder) OrCreatedByEqualsAny(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByEqualsCurrent

func (cb *CriteriaBuilder) OrCreatedByEqualsCurrent(alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByEqualsSubQuery

func (cb *CriteriaBuilder) OrCreatedByEqualsSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByIn

func (cb *CriteriaBuilder) OrCreatedByIn(createdBys []string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByInSubQuery

func (cb *CriteriaBuilder) OrCreatedByInSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByNotEquals

func (cb *CriteriaBuilder) OrCreatedByNotEquals(createdBy string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByNotEqualsAll

func (cb *CriteriaBuilder) OrCreatedByNotEqualsAll(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByNotEqualsAny

func (cb *CriteriaBuilder) OrCreatedByNotEqualsAny(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByNotEqualsCurrent

func (cb *CriteriaBuilder) OrCreatedByNotEqualsCurrent(alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByNotEqualsSubQuery

func (cb *CriteriaBuilder) OrCreatedByNotEqualsSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByNotIn

func (cb *CriteriaBuilder) OrCreatedByNotIn(createdBys []string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrCreatedByNotInSubQuery

func (cb *CriteriaBuilder) OrCreatedByNotInSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrEndsWith

func (cb *CriteriaBuilder) OrEndsWith(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrEndsWithAny

func (cb *CriteriaBuilder) OrEndsWithAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrEndsWithAnyIgnoreCase

func (cb *CriteriaBuilder) OrEndsWithAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrEndsWithIgnoreCase

func (cb *CriteriaBuilder) OrEndsWithIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrEquals

func (cb *CriteriaBuilder) OrEquals(column string, value any) ConditionBuilder

func (*CriteriaBuilder) OrEqualsAll

func (cb *CriteriaBuilder) OrEqualsAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrEqualsAny

func (cb *CriteriaBuilder) OrEqualsAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrEqualsColumn

func (cb *CriteriaBuilder) OrEqualsColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) OrEqualsExpr

func (cb *CriteriaBuilder) OrEqualsExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrEqualsSubQuery

func (cb *CriteriaBuilder) OrEqualsSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrExpr

func (cb *CriteriaBuilder) OrExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThan

func (cb *CriteriaBuilder) OrGreaterThan(column string, value any) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanAll

func (cb *CriteriaBuilder) OrGreaterThanAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanAny

func (cb *CriteriaBuilder) OrGreaterThanAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanColumn

func (cb *CriteriaBuilder) OrGreaterThanColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanExpr

func (cb *CriteriaBuilder) OrGreaterThanExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanOrEqual

func (cb *CriteriaBuilder) OrGreaterThanOrEqual(column string, value any) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanOrEqualAll

func (cb *CriteriaBuilder) OrGreaterThanOrEqualAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanOrEqualAny

func (cb *CriteriaBuilder) OrGreaterThanOrEqualAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanOrEqualColumn

func (cb *CriteriaBuilder) OrGreaterThanOrEqualColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanOrEqualExpr

func (cb *CriteriaBuilder) OrGreaterThanOrEqualExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanOrEqualSubQuery

func (cb *CriteriaBuilder) OrGreaterThanOrEqualSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrGreaterThanSubQuery

func (cb *CriteriaBuilder) OrGreaterThanSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrGroup

func (cb *CriteriaBuilder) OrGroup(builder func(ConditionBuilder)) ConditionBuilder

func (*CriteriaBuilder) OrIn

func (cb *CriteriaBuilder) OrIn(column string, values any) ConditionBuilder

func (*CriteriaBuilder) OrInExpr

func (cb *CriteriaBuilder) OrInExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrInSubQuery

func (cb *CriteriaBuilder) OrInSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrIsFalse

func (cb *CriteriaBuilder) OrIsFalse(column string) ConditionBuilder

func (*CriteriaBuilder) OrIsFalseExpr

func (cb *CriteriaBuilder) OrIsFalseExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrIsFalseSubQuery

func (cb *CriteriaBuilder) OrIsFalseSubQuery(builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrIsNotNull

func (cb *CriteriaBuilder) OrIsNotNull(column string) ConditionBuilder

func (*CriteriaBuilder) OrIsNotNullExpr

func (cb *CriteriaBuilder) OrIsNotNullExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrIsNotNullSubQuery

func (cb *CriteriaBuilder) OrIsNotNullSubQuery(builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrIsNull

func (cb *CriteriaBuilder) OrIsNull(column string) ConditionBuilder

func (*CriteriaBuilder) OrIsNullExpr

func (cb *CriteriaBuilder) OrIsNullExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrIsNullSubQuery

func (cb *CriteriaBuilder) OrIsNullSubQuery(builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrIsTrue

func (cb *CriteriaBuilder) OrIsTrue(column string) ConditionBuilder

func (*CriteriaBuilder) OrIsTrueExpr

func (cb *CriteriaBuilder) OrIsTrueExpr(builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrIsTrueSubQuery

func (cb *CriteriaBuilder) OrIsTrueSubQuery(builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrLessThan

func (cb *CriteriaBuilder) OrLessThan(column string, value any) ConditionBuilder

func (*CriteriaBuilder) OrLessThanAll

func (cb *CriteriaBuilder) OrLessThanAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrLessThanAny

func (cb *CriteriaBuilder) OrLessThanAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrLessThanColumn

func (cb *CriteriaBuilder) OrLessThanColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) OrLessThanExpr

func (cb *CriteriaBuilder) OrLessThanExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrLessThanOrEqual

func (cb *CriteriaBuilder) OrLessThanOrEqual(column string, value any) ConditionBuilder

func (*CriteriaBuilder) OrLessThanOrEqualAll

func (cb *CriteriaBuilder) OrLessThanOrEqualAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrLessThanOrEqualAny

func (cb *CriteriaBuilder) OrLessThanOrEqualAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrLessThanOrEqualColumn

func (cb *CriteriaBuilder) OrLessThanOrEqualColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) OrLessThanOrEqualExpr

func (cb *CriteriaBuilder) OrLessThanOrEqualExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrLessThanOrEqualSubQuery

func (cb *CriteriaBuilder) OrLessThanOrEqualSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrLessThanSubQuery

func (cb *CriteriaBuilder) OrLessThanSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrNotBetween

func (cb *CriteriaBuilder) OrNotBetween(column string, start, end any) ConditionBuilder

func (*CriteriaBuilder) OrNotBetweenExpr

func (cb *CriteriaBuilder) OrNotBetweenExpr(column string, startB, endB func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrNotContains

func (cb *CriteriaBuilder) OrNotContains(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrNotContainsAny

func (cb *CriteriaBuilder) OrNotContainsAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrNotContainsAnyIgnoreCase

func (cb *CriteriaBuilder) OrNotContainsAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrNotContainsIgnoreCase

func (cb *CriteriaBuilder) OrNotContainsIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrNotEndsWith

func (cb *CriteriaBuilder) OrNotEndsWith(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrNotEndsWithAny

func (cb *CriteriaBuilder) OrNotEndsWithAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrNotEndsWithAnyIgnoreCase

func (cb *CriteriaBuilder) OrNotEndsWithAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrNotEndsWithIgnoreCase

func (cb *CriteriaBuilder) OrNotEndsWithIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrNotEquals

func (cb *CriteriaBuilder) OrNotEquals(column string, value any) ConditionBuilder

func (*CriteriaBuilder) OrNotEqualsAll

func (cb *CriteriaBuilder) OrNotEqualsAll(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrNotEqualsAny

func (cb *CriteriaBuilder) OrNotEqualsAny(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrNotEqualsColumn

func (cb *CriteriaBuilder) OrNotEqualsColumn(column1, column2 string) ConditionBuilder

func (*CriteriaBuilder) OrNotEqualsExpr

func (cb *CriteriaBuilder) OrNotEqualsExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrNotEqualsSubQuery

func (cb *CriteriaBuilder) OrNotEqualsSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrNotIn

func (cb *CriteriaBuilder) OrNotIn(column string, values any) ConditionBuilder

func (*CriteriaBuilder) OrNotInExpr

func (cb *CriteriaBuilder) OrNotInExpr(column string, builder func(ExprBuilder) any) ConditionBuilder

func (*CriteriaBuilder) OrNotInSubQuery

func (cb *CriteriaBuilder) OrNotInSubQuery(column string, builder func(query SelectQuery)) ConditionBuilder

func (*CriteriaBuilder) OrNotStartsWith

func (cb *CriteriaBuilder) OrNotStartsWith(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrNotStartsWithAny

func (cb *CriteriaBuilder) OrNotStartsWithAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrNotStartsWithAnyIgnoreCase

func (cb *CriteriaBuilder) OrNotStartsWithAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrNotStartsWithIgnoreCase

func (cb *CriteriaBuilder) OrNotStartsWithIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrPKEquals

func (cb *CriteriaBuilder) OrPKEquals(pk any, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrPKIn

func (cb *CriteriaBuilder) OrPKIn(pks any, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrPKNotEquals

func (cb *CriteriaBuilder) OrPKNotEquals(pk any, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrPKNotIn

func (cb *CriteriaBuilder) OrPKNotIn(pks any, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrStartsWith

func (cb *CriteriaBuilder) OrStartsWith(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrStartsWithAny

func (cb *CriteriaBuilder) OrStartsWithAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrStartsWithAnyIgnoreCase

func (cb *CriteriaBuilder) OrStartsWithAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) OrStartsWithIgnoreCase

func (cb *CriteriaBuilder) OrStartsWithIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedAtBetween

func (cb *CriteriaBuilder) OrUpdatedAtBetween(start, end time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedAtGreaterThan

func (cb *CriteriaBuilder) OrUpdatedAtGreaterThan(updatedAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedAtGreaterThanOrEqual

func (cb *CriteriaBuilder) OrUpdatedAtGreaterThanOrEqual(updatedAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedAtLessThan

func (cb *CriteriaBuilder) OrUpdatedAtLessThan(updatedAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedAtLessThanOrEqual

func (cb *CriteriaBuilder) OrUpdatedAtLessThanOrEqual(updatedAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedAtNotBetween

func (cb *CriteriaBuilder) OrUpdatedAtNotBetween(start, end time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByEquals

func (cb *CriteriaBuilder) OrUpdatedByEquals(updatedBy string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByEqualsAll

func (cb *CriteriaBuilder) OrUpdatedByEqualsAll(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByEqualsAny

func (cb *CriteriaBuilder) OrUpdatedByEqualsAny(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByEqualsCurrent

func (cb *CriteriaBuilder) OrUpdatedByEqualsCurrent(alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByEqualsSubQuery

func (cb *CriteriaBuilder) OrUpdatedByEqualsSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByIn

func (cb *CriteriaBuilder) OrUpdatedByIn(updatedBys []string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByInSubQuery

func (cb *CriteriaBuilder) OrUpdatedByInSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByNotEquals

func (cb *CriteriaBuilder) OrUpdatedByNotEquals(updatedBy string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByNotEqualsAll

func (cb *CriteriaBuilder) OrUpdatedByNotEqualsAll(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByNotEqualsAny

func (cb *CriteriaBuilder) OrUpdatedByNotEqualsAny(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByNotEqualsCurrent

func (cb *CriteriaBuilder) OrUpdatedByNotEqualsCurrent(alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByNotEqualsSubQuery

func (cb *CriteriaBuilder) OrUpdatedByNotEqualsSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByNotIn

func (cb *CriteriaBuilder) OrUpdatedByNotIn(updatedBys []string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) OrUpdatedByNotInSubQuery

func (cb *CriteriaBuilder) OrUpdatedByNotInSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) PKEquals

func (cb *CriteriaBuilder) PKEquals(pk any, alias ...string) ConditionBuilder

func (*CriteriaBuilder) PKIn

func (cb *CriteriaBuilder) PKIn(pks any, alias ...string) ConditionBuilder

func (*CriteriaBuilder) PKNotEquals

func (cb *CriteriaBuilder) PKNotEquals(pk any, alias ...string) ConditionBuilder

func (*CriteriaBuilder) PKNotIn

func (cb *CriteriaBuilder) PKNotIn(pks any, alias ...string) ConditionBuilder

func (*CriteriaBuilder) StartsWith

func (cb *CriteriaBuilder) StartsWith(column, value string) ConditionBuilder

func (*CriteriaBuilder) StartsWithAny

func (cb *CriteriaBuilder) StartsWithAny(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) StartsWithAnyIgnoreCase

func (cb *CriteriaBuilder) StartsWithAnyIgnoreCase(column string, values []string) ConditionBuilder

func (*CriteriaBuilder) StartsWithIgnoreCase

func (cb *CriteriaBuilder) StartsWithIgnoreCase(column, value string) ConditionBuilder

func (*CriteriaBuilder) UpdatedAtBetween

func (cb *CriteriaBuilder) UpdatedAtBetween(start, end time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedAtGreaterThan

func (cb *CriteriaBuilder) UpdatedAtGreaterThan(updatedAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedAtGreaterThanOrEqual

func (cb *CriteriaBuilder) UpdatedAtGreaterThanOrEqual(updatedAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedAtLessThan

func (cb *CriteriaBuilder) UpdatedAtLessThan(updatedAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedAtLessThanOrEqual

func (cb *CriteriaBuilder) UpdatedAtLessThanOrEqual(updatedAt time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedAtNotBetween

func (cb *CriteriaBuilder) UpdatedAtNotBetween(start, end time.Time, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByEquals

func (cb *CriteriaBuilder) UpdatedByEquals(updatedBy string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByEqualsAll

func (cb *CriteriaBuilder) UpdatedByEqualsAll(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByEqualsAny

func (cb *CriteriaBuilder) UpdatedByEqualsAny(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByEqualsCurrent

func (cb *CriteriaBuilder) UpdatedByEqualsCurrent(alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByEqualsSubQuery

func (cb *CriteriaBuilder) UpdatedByEqualsSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByIn

func (cb *CriteriaBuilder) UpdatedByIn(updatedBys []string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByInSubQuery

func (cb *CriteriaBuilder) UpdatedByInSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByNotEquals

func (cb *CriteriaBuilder) UpdatedByNotEquals(updatedBy string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByNotEqualsAll

func (cb *CriteriaBuilder) UpdatedByNotEqualsAll(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByNotEqualsAny

func (cb *CriteriaBuilder) UpdatedByNotEqualsAny(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByNotEqualsCurrent

func (cb *CriteriaBuilder) UpdatedByNotEqualsCurrent(alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByNotEqualsSubQuery

func (cb *CriteriaBuilder) UpdatedByNotEqualsSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByNotIn

func (cb *CriteriaBuilder) UpdatedByNotIn(updatedBys []string, alias ...string) ConditionBuilder

func (*CriteriaBuilder) UpdatedByNotInSubQuery

func (cb *CriteriaBuilder) UpdatedByNotInSubQuery(builder func(SelectQuery), alias ...string) ConditionBuilder

type CumeDistBuilder

type CumeDistBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]
}

CumeDistBuilder defines the CUME_DIST() window function builder.

type DB

type DB interface {
	// NewSelect creates a new SELECT query builder.
	NewSelect() SelectQuery
	// NewInsert creates a new INSERT query builder.
	NewInsert() InsertQuery
	// NewUpdate creates a new UPDATE query builder.
	NewUpdate() UpdateQuery
	// NewDelete creates a new DELETE query builder.
	NewDelete() DeleteQuery
	// NewMerge creates a new MERGE (UPSERT) query builder.
	NewMerge() MergeQuery
	// NewRaw creates a raw SQL query with parameter binding.
	NewRaw(query string, args ...any) RawQuery
	// NewCreateTable creates a new CREATE TABLE query builder.
	NewCreateTable() CreateTableQuery
	// NewDropTable creates a new DROP TABLE query builder.
	NewDropTable() DropTableQuery
	// NewCreateIndex creates a new CREATE INDEX query builder.
	NewCreateIndex() CreateIndexQuery
	// NewDropIndex creates a new DROP INDEX query builder.
	NewDropIndex() DropIndexQuery
	// NewTruncateTable creates a new TRUNCATE TABLE query builder.
	NewTruncateTable() TruncateTableQuery
	// NewAddColumn creates a new ALTER TABLE ADD COLUMN query builder.
	NewAddColumn() AddColumnQuery
	// NewDropColumn creates a new ALTER TABLE DROP COLUMN query builder.
	NewDropColumn() DropColumnQuery
	// RunInTX executes fn within a read-write transaction (READ COMMITTED isolation).
	// The transaction is committed if fn returns nil, rolled back otherwise.
	RunInTX(ctx context.Context, fn func(ctx context.Context, tx DB) error) error
	// RunInReadOnlyTX executes fn within a read-only transaction (READ COMMITTED isolation).
	RunInReadOnlyTX(ctx context.Context, fn func(ctx context.Context, tx DB) error) error
	// BeginTx starts a manual transaction with the given options. Caller must commit or rollback.
	BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
	// Connection acquires a dedicated database connection from the pool.
	Connection(ctx context.Context) (*sql.Conn, error)
	// RegisterModel registers models for Bun relation mapping (e.g., many-to-many join tables).
	RegisterModel(models ...any)
	// ResetModel drops and recreates tables for the given models. Intended for testing only.
	ResetModel(ctx context.Context, models ...any) error
	// ScanRows scans all rows and closes *sql.Rows when done.
	ScanRows(ctx context.Context, rows *sql.Rows, dest ...any) error
	// ScanRow scans a single row without closing *sql.Rows.
	ScanRow(ctx context.Context, rows *sql.Rows, dest ...any) error
	// WithNamedArg returns a new DB that binds a named argument for use in raw SQL (e.g., ?name).
	WithNamedArg(name string, value any) DB
	// ModelPKs extracts primary key column names and their values from a model instance.
	ModelPKs(model any) (map[string]any, error)
	// ModelPKFields returns the primary key field descriptors for the given model.
	ModelPKFields(model any) []*PKField
	// TableOf returns the schema metadata (columns, relations, etc.) for the given model.
	TableOf(model any) *schema.Table
}

DB provides factory methods for creating queries and managing transactions.

func New

func New(db bun.IDB) DB

New creates a new DB instance that wraps the provided bun.IDB. This function is used by the dependency injection system to provide DB instances.

type DBAccessor

type DBAccessor interface {
	// DB returns the DB that created this query.
	DB() DB
}

DBAccessor provides access to the underlying DB instance.

type DDLDialect

type DDLDialect interface {
	// Name returns the dialect name (e.g., pgdialect, mysqldialect, sqlitedialect).
	Name() dialect.Name
	// IdentQuote returns the character used to quote identifiers (e.g., '"' for PostgreSQL, '`' for MySQL).
	IdentQuote() byte
}

DDLDialect defines the dialect methods needed by DDL renderers. Schema.Dialect satisfies this interface implicitly.

type DataTypeDef

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

DataTypeDef represents a SQL data type definition with optional length, precision, and scale.

type DataTypeFactory

type DataTypeFactory struct{}

DataTypeFactory provides factory methods for creating DataTypeDef instances.

func (DataTypeFactory) BigInt

func (DataTypeFactory) BigInt() DataTypeDef

func (DataTypeFactory) Binary

func (DataTypeFactory) Binary(length int) DataTypeDef

func (DataTypeFactory) Blob

func (DataTypeFactory) Boolean

func (DataTypeFactory) Boolean() DataTypeDef

func (DataTypeFactory) Char

func (DataTypeFactory) Char(length int) DataTypeDef

func (DataTypeFactory) Date

func (DataTypeFactory) DoublePrecision

func (DataTypeFactory) DoublePrecision() DataTypeDef

func (DataTypeFactory) Integer

func (DataTypeFactory) Integer() DataTypeDef

func (DataTypeFactory) JSON

func (DataTypeFactory) Numeric

func (DataTypeFactory) Numeric(precision, scale int) DataTypeDef

func (DataTypeFactory) Real

func (DataTypeFactory) SmallInt

func (DataTypeFactory) SmallInt() DataTypeDef

func (DataTypeFactory) Text

func (DataTypeFactory) Time

func (DataTypeFactory) Timestamp

func (DataTypeFactory) Timestamp() DataTypeDef

func (DataTypeFactory) TimestampWithTimeZone

func (DataTypeFactory) TimestampWithTimeZone() DataTypeDef

func (DataTypeFactory) UUID

func (DataTypeFactory) VarChar

func (DataTypeFactory) VarChar(length int) DataTypeDef

type DataTypeKind

type DataTypeKind int

DataTypeKind identifies the SQL data type category.

const (
	DataTypeSmallInt DataTypeKind = iota
	DataTypeInteger
	DataTypeBigInt
	DataTypeNumeric
	DataTypeReal
	DataTypeDoublePrecision
	DataTypeVarChar
	DataTypeChar
	DataTypeText
	DataTypeBoolean
	DataTypeDate
	DataTypeTime
	DataTypeTimestamp
	DataTypeTimestampTZ
	DataTypeBinary
	DataTypeBlob
	DataTypeUUID
	DataTypeJSON
)

type DateTimeUnit

type DateTimeUnit int

DateTimeUnit represents date and time interval units for date arithmetic operations.

const (
	UnitYear DateTimeUnit = iota
	UnitMonth
	UnitDay
	UnitHour
	UnitMinute
	UnitSecond
)

func (DateTimeUnit) ForDateTrunc

func (u DateTimeUnit) ForDateTrunc() string

ForDateTrunc returns the lowercase string for DateTrunc precision parameter.

func (DateTimeUnit) ForMySQL

func (u DateTimeUnit) ForMySQL() string

ForMySQL returns the MySQL interval unit string. Currently identical to String(); kept as a named accessor for dialect-specific extensibility.

func (DateTimeUnit) ForPostgres

func (u DateTimeUnit) ForPostgres() string

ForPostgres returns the PostgreSQL interval unit string. Currently identical to String(); kept as a named accessor for dialect-specific extensibility.

func (DateTimeUnit) ForSQLite

func (u DateTimeUnit) ForSQLite() string

ForSQLite returns the SQLite datetime modifier string (years, months, days, etc.).

func (DateTimeUnit) String

func (u DateTimeUnit) String() string

type DeleteQuery

type DeleteQuery interface {
	QueryBuilder
	QueryExecutor
	DBAccessor
	CTE[DeleteQuery]
	TableSource[DeleteQuery]
	Filterable[DeleteQuery]
	Orderable[DeleteQuery]
	Limitable[DeleteQuery]
	Returnable[DeleteQuery]
	Applier[DeleteQuery]

	// ForceDelete bypasses soft delete and performs a hard delete.
	ForceDelete() DeleteQuery
}

DeleteQuery builds and executes DELETE queries with soft delete support.

type DenseRankBuilder

type DenseRankBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]
}

DenseRankBuilder defines the DENSE_RANK() window function builder.

type DialectAction

type DialectAction func()

DialectAction is a zero-argument callback for dialect-specific side effects.

type DialectActionErr

type DialectActionErr func() error

DialectActionErr is a callback that can return an error.

type DialectExecs

type DialectExecs struct {
	Oracle    DialectAction
	SQLServer DialectAction
	Postgres  DialectAction
	MySQL     DialectAction
	SQLite    DialectAction
	Default   DialectAction
}

DialectExecs maps database dialects to side-effect callbacks.

type DialectExecsWithErr

type DialectExecsWithErr struct {
	Oracle    DialectActionErr
	SQLServer DialectActionErr
	Postgres  DialectActionErr
	MySQL     DialectActionErr
	SQLite    DialectActionErr
	Default   DialectActionErr
}

DialectExecsWithErr maps database dialects to callbacks that may return an error.

type DialectExprBuilder

type DialectExprBuilder func() schema.QueryAppender

DialectExprBuilder is a callback that returns a QueryAppender for dialect-specific expressions.

type DialectExprs

type DialectExprs struct {
	Oracle    DialectExprBuilder
	SQLServer DialectExprBuilder
	Postgres  DialectExprBuilder
	MySQL     DialectExprBuilder
	SQLite    DialectExprBuilder
	Default   DialectExprBuilder
}

DialectExprs maps database dialects to expression builders for cross-database compatibility. The Default builder is used as fallback when no dialect-specific builder is set.

type DialectFragmentBuilder

type DialectFragmentBuilder func() ([]byte, error)

DialectFragmentBuilder is a callback that returns a query fragment buffer.

type DialectFragments

DialectFragments maps database dialects to query fragment builders.

type DistinctableAggregate

type DistinctableAggregate[T any] interface {
	// Distinct marks the aggregate to operate on DISTINCT values.
	Distinct() T
}

DistinctableAggregate defines aggregate functions that support DISTINCT operations.

type DropColumnQuery

type DropColumnQuery interface {
	Executor
	TableTarget[DropColumnQuery]

	// Column specifies the columns to drop.
	Column(columns ...string) DropColumnQuery
}

DropColumnQuery builds and executes ALTER TABLE DROP COLUMN queries.

type DropIndexQuery

type DropIndexQuery interface {
	Executor

	// Index sets the index name to drop.
	Index(name string) DropIndexQuery
	// IfExists prevents errors when the index does not exist.
	IfExists() DropIndexQuery
	// Concurrently drops the index concurrently (PostgreSQL only).
	Concurrently() DropIndexQuery
	// Cascade automatically drops dependent objects.
	Cascade() DropIndexQuery
	// Restrict refuses to drop the index if any dependent objects exist.
	Restrict() DropIndexQuery
}

DropIndexQuery builds and executes DROP INDEX queries.

type DropTableQuery

type DropTableQuery interface {
	Executor
	TableTarget[DropTableQuery]
	fmt.Stringer

	// IfExists adds IF EXISTS to prevent errors when the table does not exist.
	IfExists() DropTableQuery
	// Cascade automatically drops dependent objects (e.g., indexes, views).
	Cascade() DropTableQuery
	// Restrict refuses to drop the table if any dependent objects exist (default behavior).
	Restrict() DropTableQuery
}

DropTableQuery builds and executes DROP TABLE queries.

type Executor

type Executor interface {
	// Exec executes the query and optionally scans the result into dest.
	Exec(ctx context.Context, dest ...any) (sql.Result, error)
}

Executor defines the Exec method shared by all DML and DDL queries.

type ExprBuilder

type ExprBuilder interface {
	// Column builds a column expression. If withTableAlias is false, skips automatic table alias.
	Column(column string, withTableAlias ...bool) schema.QueryAppender
	// TableColumns selects all columns of the current model's table. If withTableAlias is false, skips table alias prefix.
	TableColumns(withTableAlias ...bool) schema.QueryAppender
	// AllColumns selects all columns (*) optionally qualified with a table alias.
	AllColumns(tableAlias ...string) schema.QueryAppender
	// Null returns a SQL NULL literal.
	Null() schema.QueryAppender
	// IsNull tests whether the expression is NULL.
	IsNull(expr any) schema.QueryAppender
	// IsNotNull tests whether the expression is not NULL.
	IsNotNull(expr any) schema.QueryAppender
	// Literal wraps a Go value as a SQL literal with proper escaping.
	Literal(value any) schema.QueryAppender
	// Order builds an ORDER BY expression via the OrderBuilder DSL.
	Order(func(OrderBuilder)) schema.QueryAppender
	// Case builds a CASE WHEN ... THEN ... ELSE ... END expression via the CaseBuilder DSL.
	Case(func(CaseBuilder)) schema.QueryAppender
	// SubQuery builds a scalar subquery expression.
	SubQuery(func(SelectQuery)) schema.QueryAppender
	// Exists builds an EXISTS (subquery) expression.
	Exists(func(SelectQuery)) schema.QueryAppender
	// NotExists builds a NOT EXISTS (subquery) expression.
	NotExists(func(SelectQuery)) schema.QueryAppender
	// Paren wraps the expression in parentheses.
	Paren(expr any) schema.QueryAppender
	// Not negates the expression with NOT.
	Not(expr any) schema.QueryAppender
	// Any builds an ANY (subquery) expression for comparison with any row.
	Any(func(SelectQuery)) schema.QueryAppender
	// All builds an ALL (subquery) expression for comparison with all rows.
	All(func(SelectQuery)) schema.QueryAppender

	// Add returns left + right.
	Add(left, right any) schema.QueryAppender
	// Subtract returns left - right.
	Subtract(left, right any) schema.QueryAppender
	// Multiply returns left * right.
	Multiply(left, right any) schema.QueryAppender
	// Divide returns left / right.
	Divide(left, right any) schema.QueryAppender

	// Equals tests left = right.
	Equals(left, right any) schema.QueryAppender
	// NotEquals tests left <> right.
	NotEquals(left, right any) schema.QueryAppender
	// GreaterThan tests left > right.
	GreaterThan(left, right any) schema.QueryAppender
	// GreaterThanOrEqual tests left >= right.
	GreaterThanOrEqual(left, right any) schema.QueryAppender
	// LessThan tests left < right.
	LessThan(left, right any) schema.QueryAppender
	// LessThanOrEqual tests left <= right.
	LessThanOrEqual(left, right any) schema.QueryAppender
	// Between tests expr BETWEEN lower AND upper (inclusive).
	Between(expr, lower, upper any) schema.QueryAppender
	// NotBetween tests expr NOT BETWEEN lower AND upper.
	NotBetween(expr, lower, upper any) schema.QueryAppender
	// In tests expr IN (values...).
	In(expr any, values ...any) schema.QueryAppender
	// NotIn tests expr NOT IN (values...).
	NotIn(expr any, values ...any) schema.QueryAppender
	// IsTrue tests whether the expression evaluates to true.
	IsTrue(expr any) schema.QueryAppender
	// IsFalse tests whether the expression evaluates to false.
	IsFalse(expr any) schema.QueryAppender

	// Expr builds a raw SQL expression with optional argument binding (e.g., "? + 1", col).
	Expr(expr string, args ...any) schema.QueryAppender
	// Exprs concatenates multiple expressions with spaces.
	Exprs(exprs ...any) schema.QueryAppender
	// ExprsWithSep concatenates expressions with a custom separator.
	ExprsWithSep(separator any, exprs ...any) schema.QueryAppender
	// ExprByDialect selects the appropriate expression builder for the current database dialect.
	ExprByDialect(exprs DialectExprs) schema.QueryAppender
	// ExecByDialect executes a dialect-specific function based on the current database dialect.
	ExecByDialect(execs DialectExecs)
	// ExecByDialectWithErr executes a dialect-specific function that may return an error.
	ExecByDialectWithErr(execs DialectExecsWithErr) error
	// FragmentByDialect returns a dialect-specific SQL fragment as raw bytes.
	FragmentByDialect(fragments DialectFragments) ([]byte, error)

	// Count builds a COUNT aggregate with optional DISTINCT and FILTER via the builder DSL.
	Count(func(CountBuilder)) schema.QueryAppender
	// CountColumn builds COUNT(column) with optional DISTINCT.
	CountColumn(column string, distinct ...bool) schema.QueryAppender
	// CountAll builds COUNT(*) with optional DISTINCT.
	CountAll(distinct ...bool) schema.QueryAppender
	// Sum builds a SUM aggregate via the builder DSL.
	Sum(func(SumBuilder)) schema.QueryAppender
	// SumColumn builds SUM(column) with optional DISTINCT.
	SumColumn(column string, distinct ...bool) schema.QueryAppender
	// Avg builds an AVG aggregate via the builder DSL.
	Avg(func(AvgBuilder)) schema.QueryAppender
	// AvgColumn builds AVG(column) with optional DISTINCT.
	AvgColumn(column string, distinct ...bool) schema.QueryAppender
	// Min builds a MIN aggregate via the builder DSL.
	Min(func(MinBuilder)) schema.QueryAppender
	// MinColumn builds MIN(column).
	MinColumn(column string) schema.QueryAppender
	// Max builds a MAX aggregate via the builder DSL.
	Max(func(MaxBuilder)) schema.QueryAppender
	// MaxColumn builds MAX(column).
	MaxColumn(column string) schema.QueryAppender
	// StringAgg builds a STRING_AGG (GROUP_CONCAT) aggregate via the builder DSL.
	StringAgg(func(StringAggBuilder)) schema.QueryAppender
	// ArrayAgg builds an ARRAY_AGG aggregate via the builder DSL.
	ArrayAgg(func(ArrayAggBuilder)) schema.QueryAppender
	// JSONObjectAgg builds a JSON_OBJECT_AGG aggregate via the builder DSL.
	JSONObjectAgg(func(JSONObjectAggBuilder)) schema.QueryAppender
	// JSONArrayAgg builds a JSON_ARRAY_AGG aggregate via the builder DSL.
	JSONArrayAgg(func(JSONArrayAggBuilder)) schema.QueryAppender
	// BitOr builds a BIT_OR aggregate via the builder DSL.
	BitOr(func(BitOrBuilder)) schema.QueryAppender
	// BitAnd builds a BIT_AND aggregate via the builder DSL.
	BitAnd(func(BitAndBuilder)) schema.QueryAppender
	// BoolOr builds a BOOL_OR aggregate via the builder DSL.
	BoolOr(func(BoolOrBuilder)) schema.QueryAppender
	// BoolAnd builds a BOOL_AND aggregate via the builder DSL.
	BoolAnd(func(BoolAndBuilder)) schema.QueryAppender
	// StdDev builds a STDDEV aggregate via the builder DSL.
	StdDev(func(StdDevBuilder)) schema.QueryAppender
	// Variance builds a VARIANCE aggregate via the builder DSL.
	Variance(func(VarianceBuilder)) schema.QueryAppender

	// RowNumber builds ROW_NUMBER() OVER (...) via the builder DSL.
	RowNumber(func(RowNumberBuilder)) schema.QueryAppender
	// Rank builds RANK() OVER (...) — rows with equal values get the same rank with gaps.
	Rank(func(RankBuilder)) schema.QueryAppender
	// DenseRank builds DENSE_RANK() OVER (...) — like Rank but without gaps in ranking sequence.
	DenseRank(func(DenseRankBuilder)) schema.QueryAppender
	// PercentRank builds PERCENT_RANK() OVER (...) — relative rank as a fraction between 0 and 1.
	PercentRank(func(PercentRankBuilder)) schema.QueryAppender
	// CumeDist builds CUME_DIST() OVER (...) — cumulative distribution of a value.
	CumeDist(func(CumeDistBuilder)) schema.QueryAppender
	// NTile builds NTILE(n) OVER (...) — divides rows into n roughly equal groups.
	NTile(func(NTileBuilder)) schema.QueryAppender
	// Lag builds LAG(column, offset, default) OVER (...) — accesses a preceding row's value.
	Lag(func(LagBuilder)) schema.QueryAppender
	// Lead builds LEAD(column, offset, default) OVER (...) — accesses a following row's value.
	Lead(func(LeadBuilder)) schema.QueryAppender
	// FirstValue builds FIRST_VALUE(column) OVER (...) — returns the first value in the window frame.
	FirstValue(func(FirstValueBuilder)) schema.QueryAppender
	// LastValue builds LAST_VALUE(column) OVER (...) — returns the last value in the window frame.
	LastValue(func(LastValueBuilder)) schema.QueryAppender
	// NthValue builds NTH_VALUE(column, n) OVER (...) — returns the nth value in the window frame.
	NthValue(func(NthValueBuilder)) schema.QueryAppender
	// WinCount builds COUNT() as a window function with OVER clause.
	WinCount(func(WindowCountBuilder)) schema.QueryAppender
	// WinSum builds SUM() as a window function with OVER clause.
	WinSum(func(WindowSumBuilder)) schema.QueryAppender
	// WinAvg builds AVG() as a window function with OVER clause.
	WinAvg(func(WindowAvgBuilder)) schema.QueryAppender
	// WinMin builds MIN() as a window function with OVER clause.
	WinMin(func(WindowMinBuilder)) schema.QueryAppender
	// WinMax builds MAX() as a window function with OVER clause.
	WinMax(func(WindowMaxBuilder)) schema.QueryAppender
	// WinStringAgg builds STRING_AGG() as a window function with OVER clause.
	WinStringAgg(func(WindowStringAggBuilder)) schema.QueryAppender
	// WinArrayAgg builds ARRAY_AGG() as a window function with OVER clause.
	WinArrayAgg(func(WindowArrayAggBuilder)) schema.QueryAppender
	// WinStdDev builds STDDEV() as a window function with OVER clause.
	WinStdDev(func(WindowStdDevBuilder)) schema.QueryAppender
	// WinVariance builds VARIANCE() as a window function with OVER clause.
	WinVariance(func(WindowVarianceBuilder)) schema.QueryAppender
	// WinJSONObjectAgg builds JSON_OBJECT_AGG() as a window function with OVER clause.
	WinJSONObjectAgg(func(WindowJSONObjectAggBuilder)) schema.QueryAppender
	// WinJSONArrayAgg builds JSON_ARRAY_AGG() as a window function with OVER clause.
	WinJSONArrayAgg(func(WindowJSONArrayAggBuilder)) schema.QueryAppender
	// WinBitOr builds BIT_OR() as a window function with OVER clause.
	WinBitOr(func(WindowBitOrBuilder)) schema.QueryAppender
	// WinBitAnd builds BIT_AND() as a window function with OVER clause.
	WinBitAnd(func(WindowBitAndBuilder)) schema.QueryAppender
	// WinBoolOr builds BOOL_OR() as a window function with OVER clause.
	WinBoolOr(func(WindowBoolOrBuilder)) schema.QueryAppender
	// WinBoolAnd builds BOOL_AND() as a window function with OVER clause.
	WinBoolAnd(func(WindowBoolAndBuilder)) schema.QueryAppender

	// Concat concatenates multiple values into a single string.
	Concat(args ...any) schema.QueryAppender
	// ConcatWithSep concatenates values with a separator between each pair.
	ConcatWithSep(separator any, args ...any) schema.QueryAppender
	// SubString extracts a substring. start is 1-based; length is optional.
	SubString(expr, start any, length ...any) schema.QueryAppender
	// Upper converts a string to uppercase.
	Upper(expr any) schema.QueryAppender
	// Lower converts a string to lowercase.
	Lower(expr any) schema.QueryAppender
	// Trim removes leading and trailing whitespace.
	Trim(expr any) schema.QueryAppender
	// TrimLeft removes leading whitespace.
	TrimLeft(expr any) schema.QueryAppender
	// TrimRight removes trailing whitespace.
	TrimRight(expr any) schema.QueryAppender
	// Length returns the length in bytes.
	Length(expr any) schema.QueryAppender
	// CharLength returns the length in characters.
	CharLength(expr any) schema.QueryAppender
	// Position finds the position of substring in string (1-based, 0 if not found).
	Position(substring, str any) schema.QueryAppender
	// Left extracts the leftmost N characters.
	Left(expr, length any) schema.QueryAppender
	// Right extracts the rightmost N characters.
	Right(expr, length any) schema.QueryAppender
	// Repeat repeats the string N times.
	Repeat(expr, count any) schema.QueryAppender
	// Replace replaces all occurrences of search with replacement.
	Replace(expr, search, replacement any) schema.QueryAppender
	// Contains tests whether expr contains substr (case-sensitive).
	Contains(expr, substr any) schema.QueryAppender
	// StartsWith tests whether expr starts with prefix (case-sensitive).
	StartsWith(expr, prefix any) schema.QueryAppender
	// EndsWith tests whether expr ends with suffix (case-sensitive).
	EndsWith(expr, suffix any) schema.QueryAppender
	// ContainsIgnoreCase tests whether expr contains substr (case-insensitive).
	ContainsIgnoreCase(expr, substr any) schema.QueryAppender
	// StartsWithIgnoreCase tests whether expr starts with prefix (case-insensitive).
	StartsWithIgnoreCase(expr, prefix any) schema.QueryAppender
	// EndsWithIgnoreCase tests whether expr ends with suffix (case-insensitive).
	EndsWithIgnoreCase(expr, suffix any) schema.QueryAppender
	// Reverse reverses the string.
	Reverse(expr any) schema.QueryAppender

	// CurrentDate returns the current date (without time).
	CurrentDate() schema.QueryAppender
	// CurrentTime returns the current time (without date).
	CurrentTime() schema.QueryAppender
	// CurrentTimestamp returns the current date and time with timezone.
	CurrentTimestamp() schema.QueryAppender
	// Now is an alias for CurrentTimestamp.
	Now() schema.QueryAppender
	// ExtractYear extracts the year component from a date/timestamp.
	ExtractYear(expr any) schema.QueryAppender
	// ExtractMonth extracts the month component (1-12) from a date/timestamp.
	ExtractMonth(expr any) schema.QueryAppender
	// ExtractDay extracts the day component from a date/timestamp.
	ExtractDay(expr any) schema.QueryAppender
	// ExtractHour extracts the hour component from a time/timestamp.
	ExtractHour(expr any) schema.QueryAppender
	// ExtractMinute extracts the minute component from a time/timestamp.
	ExtractMinute(expr any) schema.QueryAppender
	// ExtractSecond extracts the second component from a time/timestamp.
	ExtractSecond(expr any) schema.QueryAppender
	// DateTrunc truncates a date/timestamp to the specified precision unit.
	DateTrunc(unit DateTimeUnit, expr any) schema.QueryAppender
	// DateAdd adds an interval to a date/timestamp.
	DateAdd(expr, interval any, unit DateTimeUnit) schema.QueryAppender
	// DateSubtract subtracts an interval from a date/timestamp.
	DateSubtract(expr, interval any, unit DateTimeUnit) schema.QueryAppender
	// DateDiff computes the difference between two dates in the specified unit.
	DateDiff(start, end any, unit DateTimeUnit) schema.QueryAppender
	// Age computes the interval between two timestamps.
	Age(start, end any) schema.QueryAppender

	// Abs returns the absolute value.
	Abs(expr any) schema.QueryAppender
	// Ceil rounds up to the nearest integer.
	Ceil(expr any) schema.QueryAppender
	// Floor rounds down to the nearest integer.
	Floor(expr any) schema.QueryAppender
	// Round rounds to the specified precision (default 0 decimal places).
	Round(expr any, precision ...any) schema.QueryAppender
	// Trunc truncates to the specified precision without rounding.
	Trunc(expr any, precision ...any) schema.QueryAppender
	// Power returns base raised to the exponent power.
	Power(base, exponent any) schema.QueryAppender
	// Sqrt returns the square root.
	Sqrt(expr any) schema.QueryAppender
	// Exp returns e raised to the given power.
	Exp(expr any) schema.QueryAppender
	// Ln returns the natural logarithm (base e).
	Ln(expr any) schema.QueryAppender
	// Log returns the logarithm with specified base (default base 10).
	Log(expr any, base ...any) schema.QueryAppender
	// Sin returns the sine of the angle in radians.
	Sin(expr any) schema.QueryAppender
	// Cos returns the cosine of the angle in radians.
	Cos(expr any) schema.QueryAppender
	// Tan returns the tangent of the angle in radians.
	Tan(expr any) schema.QueryAppender
	// Asin returns the arc sine in radians.
	Asin(expr any) schema.QueryAppender
	// Acos returns the arc cosine in radians.
	Acos(expr any) schema.QueryAppender
	// Atan returns the arc tangent in radians.
	Atan(expr any) schema.QueryAppender
	// Pi returns the constant pi.
	Pi() schema.QueryAppender
	// Random returns a random value between 0.0 and 1.0.
	Random() schema.QueryAppender
	// Sign returns -1, 0, or 1.
	Sign(expr any) schema.QueryAppender
	// Mod returns the remainder of dividend / divisor.
	Mod(dividend, divisor any) schema.QueryAppender
	// Greatest returns the largest value among the arguments.
	Greatest(args ...any) schema.QueryAppender
	// Least returns the smallest value among the arguments.
	Least(args ...any) schema.QueryAppender

	// Coalesce returns the first non-NULL value among the arguments.
	Coalesce(args ...any) schema.QueryAppender
	// NullIf returns null if the two arguments are equal, otherwise the first argument.
	NullIf(expr1, expr2 any) schema.QueryAppender
	// IfNull returns defaultValue if expr is null, otherwise expr.
	IfNull(expr, defaultValue any) schema.QueryAppender

	// ToString casts the expression to a text/varchar type.
	ToString(expr any) schema.QueryAppender
	// ToInteger casts the expression to an integer type.
	ToInteger(expr any) schema.QueryAppender
	// ToDecimal casts the expression to a decimal/numeric type with optional precision.
	ToDecimal(expr any, precision ...any) schema.QueryAppender
	// ToFloat casts the expression to a floating-point type.
	ToFloat(expr any) schema.QueryAppender
	// ToBool casts the expression to a boolean type.
	ToBool(expr any) schema.QueryAppender
	// ToDate casts the expression to a date type with optional format pattern.
	ToDate(expr any, format ...any) schema.QueryAppender
	// ToTime casts the expression to a time type with optional format pattern.
	ToTime(expr any, format ...any) schema.QueryAppender
	// ToTimestamp casts the expression to a timestamp type with optional format pattern.
	ToTimestamp(expr any, format ...any) schema.QueryAppender
	// ToJSON casts the expression to a JSON/JSONB type.
	ToJSON(expr any) schema.QueryAppender

	// JSONExtract extracts a value from a JSON document at the given path.
	JSONExtract(json, path any) schema.QueryAppender
	// JSONUnquote removes JSON quoting from a string value.
	JSONUnquote(expr any) schema.QueryAppender
	// JSONArray constructs a JSON array from the given values.
	JSONArray(args ...any) schema.QueryAppender
	// JSONObject constructs a JSON object from alternating key-value pairs.
	JSONObject(keyValues ...any) schema.QueryAppender
	// JSONContains tests whether a JSON document contains a specific value.
	JSONContains(json, value any) schema.QueryAppender
	// JSONContainsPath tests whether a JSON document contains data at the given path.
	JSONContainsPath(json, path any) schema.QueryAppender
	// JSONKeys returns the keys of a JSON object, optionally at the given path.
	JSONKeys(json any, path ...any) schema.QueryAppender
	// JSONLength returns the number of elements in a JSON array or keys in a JSON object.
	JSONLength(json any, path ...any) schema.QueryAppender
	// JSONType returns the type of a JSON value (e.g., "object", "array", "string").
	JSONType(json any, path ...any) schema.QueryAppender
	// JSONValid tests whether a string is valid JSON.
	JSONValid(expr any) schema.QueryAppender
	// JSONSet sets value at path (insert or update).
	JSONSet(json, path, value any) schema.QueryAppender
	// JSONInsert inserts value at path only if path doesn't exist.
	JSONInsert(json, path, value any) schema.QueryAppender
	// JSONReplace replaces value at path only if path exists.
	JSONReplace(json, path, value any) schema.QueryAppender
	// JSONArrayAppend appends a value to the JSON array at the given path.
	JSONArrayAppend(json, path, value any) schema.QueryAppender

	// Decode implements Oracle-style case expression.
	// Usage: Decode(expr, search1, result1, search2, result2, ..., defaultResult)
	Decode(args ...any) schema.QueryAppender
}

ExprBuilder provides a fluent API for building SQL expressions including aggregates, window functions, string/date/math functions, and conditional logic.

type Expressions

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

func (*Expressions) AppendQuery

func (e *Expressions) AppendQuery(gen schema.QueryGen, b []byte) ([]byte, error)

type Filterable

type Filterable[T Executor] interface {
	// Where adds WHERE conditions using the ConditionBuilder DSL.
	Where(func(ConditionBuilder)) T
	// WherePK adds a WHERE clause matching the model's primary key columns.
	WherePK(columns ...string) T
	// WhereDeleted restricts results to soft-deleted rows only.
	WhereDeleted() T
	// IncludeDeleted disables the automatic soft delete filter to include deleted rows.
	IncludeDeleted() T
}

Filterable defines WHERE clause methods including soft delete support.

type FirstValueBuilder

type FirstValueBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]
	NullHandlingBuilder[FirstValueBuilder]

	// Column specifies the column to retrieve the first value from.
	Column(column string) FirstValueBuilder
	// Expr specifies a raw expression to retrieve the first value from.
	Expr(expr any) FirstValueBuilder
}

FirstValueBuilder defines the FIRST_VALUE() window function builder.

type ForeignKeyBuilder

type ForeignKeyBuilder interface {
	// Name sets an explicit constraint name.
	// SQL: CONSTRAINT "name" FOREIGN KEY (...)
	Name(name string) ForeignKeyBuilder
	// Columns sets the local columns that form the foreign key.
	Columns(columns ...string) ForeignKeyBuilder
	// References sets the referenced table and columns.
	References(table string, columns ...string) ForeignKeyBuilder
	// OnDelete sets the referential action for DELETE operations.
	OnDelete(action ReferenceAction) ForeignKeyBuilder
	// OnUpdate sets the referential action for UPDATE operations.
	OnUpdate(action ReferenceAction) ForeignKeyBuilder
}

ForeignKeyBuilder provides a fluent API for defining table-level foreign key constraints.

type ForeignKeyDef

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

ForeignKeyDef holds the definition of a foreign key constraint.

func (*ForeignKeyDef) Columns

func (f *ForeignKeyDef) Columns(columns ...string) ForeignKeyBuilder

func (*ForeignKeyDef) Name

func (f *ForeignKeyDef) Name(name string) ForeignKeyBuilder

func (*ForeignKeyDef) OnDelete

func (f *ForeignKeyDef) OnDelete(action ReferenceAction) ForeignKeyBuilder

func (*ForeignKeyDef) OnUpdate

func (f *ForeignKeyDef) OnUpdate(action ReferenceAction) ForeignKeyBuilder

func (*ForeignKeyDef) References

func (f *ForeignKeyDef) References(table string, columns ...string) ForeignKeyBuilder

type FrameBoundKind

type FrameBoundKind int

FrameBoundKind specifies the bound type in a window frame.

const (
	FrameBoundNone FrameBoundKind = iota
	FrameBoundUnboundedPreceding
	FrameBoundUnboundedFollowing
	FrameBoundCurrentRow
	FrameBoundPreceding
	FrameBoundFollowing
)

func (FrameBoundKind) String

func (f FrameBoundKind) String() string

type FrameType

type FrameType int

FrameType specifies the window frame unit.

const (
	FrameDefault FrameType = iota
	FrameRows
	FrameRange
	FrameGroups
)

func (FrameType) String

func (f FrameType) String() string

type FromDirection

type FromDirection int

FromDirection specifies the direction for window frame FROM clause.

const (
	FromDefault FromDirection = iota
	FromFirst
	FromLast
)

func (FromDirection) String

func (f FromDirection) String() string

type FuzzyKind

type FuzzyKind uint8

FuzzyKind represents the wildcard placement for LIKE patterns.

const (
	FuzzyStarts   FuzzyKind = 0 // value%
	FuzzyEnds     FuzzyKind = 1 // %value
	FuzzyContains FuzzyKind = 2 // %value%
)

func (FuzzyKind) BuildPattern

func (k FuzzyKind) BuildPattern(value string) string

BuildPattern constructs a LIKE pattern string based on the FuzzyKind.

type IDHandler

type IDHandler struct{}

IDHandler generates unique IDs for string primary key fields on insert.

func (*IDHandler) Name

func (*IDHandler) Name() string

func (*IDHandler) OnInsert

func (*IDHandler) OnInsert(_ *BunInsertQuery, _ *schema.Table, field *schema.Field, _ any, value reflect.Value)

OnInsert generates an ID for zero-valued string PK fields.

type IDModel

type IDModel struct {
	ID string `json:"id" bun:"id,pk"`
}

IDModel contains only the primary key field.

type IndexMethod

type IndexMethod int

IndexMethod specifies the index access method.

const (
	IndexBTree  IndexMethod = iota // All databases
	IndexHash                      // PostgreSQL, MySQL
	IndexGIN                       // PostgreSQL
	IndexGiST                      // PostgreSQL
	IndexSPGiST                    // PostgreSQL
	IndexBRIN                      // PostgreSQL
)

func (IndexMethod) String

func (m IndexMethod) String() string

type InsertAutoColumnPlanItem

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

type InsertColumnHandler

type InsertColumnHandler interface {
	ColumnHandler
	// OnInsert sets the column value automatically when a new row is inserted.
	OnInsert(query *BunInsertQuery, table *schema.Table, field *schema.Field, model any, value reflect.Value)
}

InsertColumnHandler manages columns automatically during insert operations.

type InsertQuery

type InsertQuery interface {
	QueryBuilder
	QueryExecutor
	DBAccessor
	CTE[InsertQuery]
	TableSource[InsertQuery]
	Selectable[InsertQuery]
	ColumnUpdatable[InsertQuery]
	Returnable[InsertQuery]
	Applier[InsertQuery]

	// OnConflict configures conflict handling (UPSERT).
	OnConflict(func(ConflictBuilder)) InsertQuery
}

InsertQuery builds and executes INSERT queries with conflict resolution and RETURNING support.

type InsertQueryConflictBuilder

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

func (*InsertQueryConflictBuilder) Columns

func (b *InsertQueryConflictBuilder) Columns(columns ...string) ConflictBuilder

func (*InsertQueryConflictBuilder) Constraint

func (*InsertQueryConflictBuilder) DoNothing

func (b *InsertQueryConflictBuilder) DoNothing()

func (*InsertQueryConflictBuilder) DoUpdate

func (*InsertQueryConflictBuilder) Where

type InsertQueryConflictUpdateBuilder

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

InsertQueryConflictUpdateBuilder implements ConflictUpdateBuilder interface.

func (*InsertQueryConflictUpdateBuilder) Set

func (*InsertQueryConflictUpdateBuilder) SetExpr

func (*InsertQueryConflictUpdateBuilder) Where

type JSONArrayAggBuilder

JSONArrayAggBuilder defines the JSON_ARRAY_AGG aggregate function builder.

type JSONObjectAggBuilder

type JSONObjectAggBuilder interface {
	BaseAggregate[JSONObjectAggBuilder]
	DistinctableAggregate[JSONObjectAggBuilder]
	OrderableAggregate[JSONObjectAggBuilder]

	// KeyColumn specifies the column to use as JSON object keys.
	KeyColumn(column string) JSONObjectAggBuilder
	// KeyExpr specifies a raw expression to use as JSON object keys.
	KeyExpr(expr any) JSONObjectAggBuilder
}

JSONObjectAggBuilder defines the JSON_OBJECT_AGG aggregate function builder.

type JoinOperations

type JoinOperations[T any] interface {
	// Join performs an INNER JOIN using a model as the table source.
	Join(model any, builder func(ConditionBuilder), alias ...string) T
	// JoinTable performs an INNER JOIN using a raw table name.
	JoinTable(name string, builder func(ConditionBuilder), alias ...string) T
	// JoinSubQuery performs an INNER JOIN using a subquery as the table source.
	JoinSubQuery(sqBuilder func(query SelectQuery), cBuilder func(ConditionBuilder), alias ...string) T
	// JoinExpr performs an INNER JOIN using a SQL expression as the table source.
	JoinExpr(eBuilder func(ExprBuilder) any, cBuilder func(ConditionBuilder), alias ...string) T

	// LeftJoin performs a LEFT OUTER JOIN using a model as the table source.
	LeftJoin(model any, builder func(ConditionBuilder), alias ...string) T
	// LeftJoinTable performs a LEFT OUTER JOIN using a raw table name.
	LeftJoinTable(name string, builder func(ConditionBuilder), alias ...string) T
	// LeftJoinSubQuery performs a LEFT OUTER JOIN using a subquery as the table source.
	LeftJoinSubQuery(sqBuilder func(query SelectQuery), cBuilder func(ConditionBuilder), alias ...string) T
	// LeftJoinExpr performs a LEFT OUTER JOIN using a SQL expression as the table source.
	LeftJoinExpr(eBuilder func(ExprBuilder) any, cBuilder func(ConditionBuilder), alias ...string) T

	// RightJoin performs a RIGHT OUTER JOIN using a model as the table source.
	RightJoin(model any, builder func(ConditionBuilder), alias ...string) T
	// RightJoinTable performs a RIGHT OUTER JOIN using a raw table name.
	RightJoinTable(name string, builder func(ConditionBuilder), alias ...string) T
	// RightJoinSubQuery performs a RIGHT OUTER JOIN using a subquery as the table source.
	RightJoinSubQuery(sqBuilder func(query SelectQuery), cBuilder func(ConditionBuilder), alias ...string) T
	// RightJoinExpr performs a RIGHT OUTER JOIN using a SQL expression as the table source.
	RightJoinExpr(eBuilder func(ExprBuilder) any, cBuilder func(ConditionBuilder), alias ...string) T

	// FullJoin performs a FULL OUTER JOIN using a model as the table source.
	FullJoin(model any, builder func(ConditionBuilder), alias ...string) T
	// FullJoinTable performs a FULL OUTER JOIN using a raw table name.
	FullJoinTable(name string, builder func(ConditionBuilder), alias ...string) T
	// FullJoinSubQuery performs a FULL OUTER JOIN using a subquery as the table source.
	FullJoinSubQuery(sqBuilder func(query SelectQuery), cBuilder func(ConditionBuilder), alias ...string) T
	// FullJoinExpr performs a FULL OUTER JOIN using a SQL expression as the table source.
	FullJoinExpr(eBuilder func(ExprBuilder) any, cBuilder func(ConditionBuilder), alias ...string) T

	// CrossJoin performs a CROSS JOIN using a model as the table source (no join condition).
	CrossJoin(model any, alias ...string) T
	// CrossJoinTable performs a CROSS JOIN using a raw table name.
	CrossJoinTable(name string, alias ...string) T
	// CrossJoinSubQuery performs a CROSS JOIN using a subquery as the table source.
	CrossJoinSubQuery(sqBuilder func(query SelectQuery), alias ...string) T
	// CrossJoinExpr performs a CROSS JOIN using a SQL expression as the table source.
	CrossJoinExpr(eBuilder func(ExprBuilder) any, alias ...string) T
}

JoinOperations defines all standard SQL join types (INNER, LEFT, RIGHT, FULL, CROSS) with model, table name, subquery, and expression source variants.

type JoinType

type JoinType int

JoinType specifies the type of JOIN operation.

const (
	JoinDefault JoinType = iota
	JoinInner
	JoinLeft
	JoinRight
	JoinFull // Note: Not supported by SQLite
	JoinCross
)

func (JoinType) String

func (j JoinType) String() string

type LagBuilder

type LagBuilder interface {
	WindowPartitionable[WindowPartitionBuilder]

	// Column specifies the column to access from the previous row.
	Column(column string) LagBuilder
	// Expr specifies a raw expression to access from the previous row.
	Expr(expr any) LagBuilder
	// Offset sets the number of rows to look back (default 1).
	Offset(offset int) LagBuilder
	// DefaultValue sets the fallback value when no previous row exists.
	DefaultValue(value any) LagBuilder
}

LagBuilder defines the LAG() window function builder.

type LastValueBuilder

type LastValueBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]
	NullHandlingBuilder[LastValueBuilder]

	// Column specifies the column to retrieve the last value from.
	Column(column string) LastValueBuilder
	// Expr specifies a raw expression to retrieve the last value from.
	Expr(expr any) LastValueBuilder
}

LastValueBuilder defines the LAST_VALUE() window function builder.

type LeadBuilder

type LeadBuilder interface {
	WindowPartitionable[WindowPartitionBuilder]

	// Column specifies the column to access from the next row.
	Column(column string) LeadBuilder
	// Expr specifies a raw expression to access from the next row.
	Expr(expr any) LeadBuilder
	// Offset sets the number of rows to look ahead (default 1).
	Offset(offset int) LeadBuilder
	// DefaultValue sets the fallback value when no next row exists.
	DefaultValue(value any) LeadBuilder
}

LeadBuilder defines the LEAD() window function builder.

type Limitable

type Limitable[T Executor] interface {
	// Limit restricts the maximum number of rows returned.
	Limit(limit int) T
}

Limitable defines the LIMIT clause for result set size control.

type MaxBuilder

type MaxBuilder interface {
	BaseAggregate[MaxBuilder]
}

MaxBuilder defines the MAX aggregate function builder.

type MergeInsertBuilder

type MergeInsertBuilder interface {
	// Value sets a single column to a specific value for insertion.
	Value(column string, value any) MergeInsertBuilder
	// ValueExpr sets a single column using an expression builder for insertion.
	ValueExpr(column string, builder func(ExprBuilder) any) MergeInsertBuilder
	// Values sets multiple columns from the SOURCE table (e.g., INSERT (col1, col2) VALUES (SOURCE.col1, SOURCE.col2)).
	// Each column will be inserted with its corresponding value from the source.
	Values(columns ...string) MergeInsertBuilder
	// ValuesAll sets all columns from the table schema to their corresponding SOURCE values for insertion.
	// Columns specified in excludedColumns will be skipped (useful for excluding auto-generated columns).
	ValuesAll(excludedColumns ...string) MergeInsertBuilder
}

MergeInsertBuilder is an interface for configuring INSERT actions in MERGE queries. It allows specifying which columns and values to insert. This builder is used within ThenInsert() to configure the insert operation.

type MergeQuery

type MergeQuery interface {
	QueryBuilder
	QueryExecutor
	DBAccessor
	CTE[MergeQuery]
	TableSource[MergeQuery]
	Returnable[MergeQuery]
	Applier[MergeQuery]

	// Using specifies the source table for the merge using a model.
	Using(model any, alias ...string) MergeQuery
	// UsingTable specifies the source table for the merge by raw name.
	UsingTable(table string, alias ...string) MergeQuery
	// UsingExpr specifies the source for the merge using a SQL expression.
	UsingExpr(builder func(ExprBuilder) any, alias ...string) MergeQuery
	// UsingSubQuery specifies the source for the merge using a subquery.
	UsingSubQuery(builder func(SelectQuery), alias ...string) MergeQuery

	// On specifies the merge condition that determines matches between target and source.
	On(func(ConditionBuilder)) MergeQuery

	// WhenMatched configures actions for rows that match the ON condition.
	WhenMatched(builder ...func(ConditionBuilder)) MergeWhenBuilder
	// WhenNotMatched configures actions for source rows with no target match.
	WhenNotMatched(builder ...func(ConditionBuilder)) MergeWhenBuilder
	// WhenNotMatchedByTarget is an alias for WhenNotMatched (SQL Server syntax).
	WhenNotMatchedByTarget(builder ...func(ConditionBuilder)) MergeWhenBuilder
	// WhenNotMatchedBySource configures actions for target rows with no source match.
	WhenNotMatchedBySource(builder ...func(ConditionBuilder)) MergeWhenBuilder
}

MergeQuery builds and executes MERGE (UPSERT) queries with conditional match/no-match actions.

type MergeUpdateBuilder

type MergeUpdateBuilder interface {
	// Set sets a single column to a specific value.
	Set(column string, value any) MergeUpdateBuilder
	// SetExpr sets a single column using an expression builder.
	SetExpr(column string, builder func(ExprBuilder) any) MergeUpdateBuilder
	// SetColumns sets multiple columns from the SOURCE table (e.g., column = SOURCE.column).
	// Each column will be updated with its corresponding value from the source.
	SetColumns(columns ...string) MergeUpdateBuilder
	// SetAll sets all columns from the table schema to their corresponding SOURCE values.
	// Columns specified in excludedColumns will be skipped (useful for excluding id, created_at, etc.).
	SetAll(excludedColumns ...string) MergeUpdateBuilder
}

MergeUpdateBuilder is an interface for configuring UPDATE actions in MERGE queries. It allows setting column values and expressions for update operations. This builder is used within ThenUpdate() to specify which columns should be updated.

type MergeWhenBuilder

type MergeWhenBuilder interface {
	// ThenUpdate specifies an UPDATE action for the WHEN clause.
	// Use the provided MergeUpdateBuilder to configure which columns to update.
	ThenUpdate(func(MergeUpdateBuilder)) MergeQuery
	// ThenInsert specifies an INSERT action for the WHEN clause.
	// Use the provided MergeInsertBuilder to configure which columns and values to insert.
	ThenInsert(func(MergeInsertBuilder)) MergeQuery
	// ThenDelete specifies a DELETE action for the WHEN clause.
	ThenDelete() MergeQuery
	// ThenDoNothing specifies no action for the WHEN clause.
	ThenDoNothing() MergeQuery
}

MergeWhenBuilder is an interface for defining actions in MERGE WHEN clauses. It provides methods to specify what action to take when merge conditions are met. This interface is returned by WhenMatched, WhenNotMatched, and related methods on MergeQuery.

type MinBuilder

type MinBuilder interface {
	BaseAggregate[MinBuilder]
}

MinBuilder defines the MIN aggregate function builder.

type Model

type Model struct {
	ID            string         `json:"id" bun:"id,pk"`
	CreatedAt     timex.DateTime `json:"createdAt" bun:",notnull,type:timestamp,default:CURRENT_TIMESTAMP,skipupdate"`
	CreatedBy     string         `json:"createdBy" bun:",notnull,skipupdate" mold:"translate=user?"`
	CreatedByName string         `json:"createdByName" bun:",scanonly"`
	UpdatedAt     timex.DateTime `json:"updatedAt" bun:",notnull,type:timestamp,default:CURRENT_TIMESTAMP"`
	UpdatedBy     string         `json:"updatedBy" bun:",notnull" mold:"translate=user?"`
	UpdatedByName string         `json:"updatedByName" bun:",scanonly"`
}

Model is the base model with primary key and full audit tracking.

type NTileBuilder

type NTileBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]

	// Buckets sets the number of roughly equal-sized groups to distribute rows into.
	Buckets(n int) NTileBuilder
}

NTileBuilder defines the NTILE(n) window function builder.

type NthValueBuilder

type NthValueBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]
	NullHandlingBuilder[NthValueBuilder]

	// Column specifies the column to retrieve the Nth value from.
	Column(column string) NthValueBuilder
	// Expr specifies a raw expression to retrieve the Nth value from.
	Expr(expr any) NthValueBuilder
	// N sets the position (1-based) of the value to retrieve within the window frame.
	N(n int) NthValueBuilder
	// FromFirst counts the position from the first row of the window frame.
	FromFirst() NthValueBuilder
	// FromLast counts the position from the last row of the window frame.
	FromLast() NthValueBuilder
}

NthValueBuilder defines the NTH_VALUE() window function builder.

type NullHandlingBuilder

type NullHandlingBuilder[T any] interface {
	// IgnoreNulls configures the aggregate to ignore NULL values.
	IgnoreNulls() T
	// RespectNulls configures the aggregate to respect NULL values.
	RespectNulls() T
}

NullHandlingBuilder defines aggregate functions that support NULL value handling.

type NullsMode

type NullsMode int

NullsMode controls how NULLs are treated in window functions.

const (
	NullsDefault NullsMode = iota
	NullsRespect
	NullsIgnore
)

func (NullsMode) String

func (n NullsMode) String() string

type OrderBuilder

type OrderBuilder interface {
	// Column specifies the column name to order by
	Column(column string) OrderBuilder
	// Expr allows ordering by a raw SQL expression instead of a column name.
	Expr(expr any) OrderBuilder
	// Asc sets ascending sort direction.
	Asc() OrderBuilder
	// Desc sets descending sort direction.
	Desc() OrderBuilder
	// NullsFirst places NULL values before non-NULL values in the sort order.
	NullsFirst() OrderBuilder
	// NullsLast places NULL values after non-NULL values in the sort order.
	NullsLast() OrderBuilder
}

OrderBuilder provides a fluent interface for building ORDER BY clauses.

type Orderable

type Orderable[T Executor] interface {
	// OrderBy adds ascending ORDER BY clauses for the specified columns.
	OrderBy(columns ...string) T
	// OrderByDesc adds descending ORDER BY clauses for the specified columns.
	OrderByDesc(columns ...string) T
	// OrderByExpr adds an ORDER BY clause using a custom expression with full control over direction and nulls ordering.
	OrderByExpr(func(ExprBuilder) any) T
}

Orderable defines ORDER BY methods for query results.

type OrderableAggregate

type OrderableAggregate[T any] interface {
	// OrderBy adds ORDER BY clauses with ascending direction inside the aggregate.
	OrderBy(columns ...string) T
	// OrderByDesc adds ORDER BY clauses with descending direction inside the aggregate.
	OrderByDesc(columns ...string) T
	// OrderByExpr adds an ORDER BY clause based on a raw expression inside the aggregate.
	OrderByExpr(expr any) T
}

OrderableAggregate defines aggregate functions that support ordering.

type PKConditionBuilder

type PKConditionBuilder interface {
	// PKEquals is a condition that checks if the primary key is equal to a value.
	PKEquals(pk any, alias ...string) ConditionBuilder
	// OrPKEquals is a condition that checks if the primary key is equal to a value.
	OrPKEquals(pk any, alias ...string) ConditionBuilder
	// PKNotEquals is a condition that checks if the primary key is not equal to a value.
	PKNotEquals(pk any, alias ...string) ConditionBuilder
	// OrPKNotEquals is a condition that checks if the primary key is not equal to a value.
	OrPKNotEquals(pk any, alias ...string) ConditionBuilder
	// PKIn is a condition that checks if the primary key is in a list of values.
	PKIn(pks any, alias ...string) ConditionBuilder
	// OrPKIn is a condition that checks if the primary key is in a list of values.
	OrPKIn(pks any, alias ...string) ConditionBuilder
	// PKNotIn is a condition that checks if the primary key is not in a list of values.
	PKNotIn(pks any, alias ...string) ConditionBuilder
	// OrPKNotIn is a condition that checks if the primary key is not in a list of values.
	OrPKNotIn(pks any, alias ...string) ConditionBuilder
}

PKConditionBuilder is a builder for primary key conditions.

type PKField

type PKField struct {
	// Field is the Go struct field name, e.g. "UserID".
	Field string
	// Column is the database column name as defined in schema, e.g. "user_id".
	Column string
	// Name is the lower camel-case alias, usually used in params or API payloads, e.g. "userID".
	Name string
	// contains filtered or unexported fields
}

PKField describes a model's primary key field with common aliases. It provides helpers to get/set the PK value on a concrete model instance.

func NewPKField

func NewPKField(field *schema.Field) *PKField

NewPKField constructs a PKField helper from a bun schema.Field. Field is the Go struct field name; Column is the DB column name; Name is a lower-camel alias commonly used in params or API payloads.

func (*PKField) Set

func (p *PKField) Set(model, value any) error

Set writes the provided value into the model's primary key field. The model must be a pointer to struct. Basic kinds supported: - string (and *string) - int/int32/int64 (and their pointer forms) For unsupported kinds, an error is returned.

func (*PKField) Value

func (p *PKField) Value(model any) (any, error)

Value returns the primary key value from the given model instance. The model must be a pointer to struct; otherwise an error is returned. It leverages bun's schema.Field to read the concrete field value safely.

type PartitionStrategy

type PartitionStrategy int

PartitionStrategy specifies the table partitioning strategy.

const (
	PartitionRange PartitionStrategy = iota // SQL:2011
	PartitionList                           // SQL:2011
	PartitionHash                           // SQL:2011
)

func (PartitionStrategy) String

func (p PartitionStrategy) String() string

type PercentRankBuilder

type PercentRankBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]
}

PercentRankBuilder defines the PERCENT_RANK() window function builder.

type PrimaryKeyBuilder

type PrimaryKeyBuilder interface {
	// Name sets an explicit constraint name.
	// SQL: CONSTRAINT "name" PRIMARY KEY (...)
	Name(name string) PrimaryKeyBuilder
	// Columns sets the columns that form the primary key.
	Columns(columns ...string) PrimaryKeyBuilder
}

PrimaryKeyBuilder provides a fluent API for defining table-level PRIMARY KEY constraints.

type PrimaryKeyDef

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

PrimaryKeyDef holds the definition of a primary key constraint.

func (*PrimaryKeyDef) Columns

func (p *PrimaryKeyDef) Columns(columns ...string) PrimaryKeyBuilder

func (*PrimaryKeyDef) Name

func (p *PrimaryKeyDef) Name(name string) PrimaryKeyBuilder

type QueryBuilder

type QueryBuilder interface {
	fmt.Stringer

	// Dialect returns the current database dialect (PostgreSQL, MySQL, or SQLite).
	Dialect() schema.Dialect
	// GetTable returns the Bun schema table metadata for the query's model.
	GetTable() *schema.Table
	// Query returns the underlying bun.Query instance.
	Query() bun.Query
	// ExprBuilder returns an expression builder for constructing SQL expressions.
	ExprBuilder() ExprBuilder
	// CreateSubQuery wraps a raw bun.SelectQuery into a VEF SelectQuery for use as a subquery.
	CreateSubQuery(subQuery *bun.SelectQuery) SelectQuery
	// BuildSubQuery creates a bun.SelectQuery by applying the builder function to a new subquery.
	BuildSubQuery(builder func(query SelectQuery)) *bun.SelectQuery
	// BuildCondition creates a WHERE condition clause by applying the builder function.
	BuildCondition(builder func(ConditionBuilder)) interface {
		schema.QueryAppender
		ConditionBuilder
	}
}

QueryBuilder defines the common interface for building subqueries and conditions.

type QueryConditionBuilder

type QueryConditionBuilder struct {
	*CriteriaBuilder
}

QueryConditionBuilder is a builder for building query conditions.

type QueryExecutor

type QueryExecutor interface {
	Executor

	// Scan executes the query and scans result rows into dest.
	Scan(ctx context.Context, dest ...any) error
}

QueryExecutor extends Executor with Scan for reading result rows.

type QueryExprBuilder

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

QueryExprBuilder implements the ExprBuilder interface, providing methods to build various SQL expressions.

func (*QueryExprBuilder) Abs

func (*QueryExprBuilder) Acos

func (b *QueryExprBuilder) Acos(expr any) schema.QueryAppender

func (*QueryExprBuilder) Add

func (b *QueryExprBuilder) Add(left, right any) schema.QueryAppender

func (*QueryExprBuilder) Age

func (b *QueryExprBuilder) Age(start, end any) schema.QueryAppender

Age returns the age (interval) between two timestamps. Returns a PostgreSQL-compatible interval string in format: "X years Y mons Z days" This provides a symbolic result using field-by-field subtraction with adjustments.

func (*QueryExprBuilder) All

func (b *QueryExprBuilder) All(builder func(SelectQuery)) schema.QueryAppender

func (*QueryExprBuilder) AllColumns

func (b *QueryExprBuilder) AllColumns(tableAlias ...string) schema.QueryAppender

func (*QueryExprBuilder) Any

func (b *QueryExprBuilder) Any(builder func(SelectQuery)) schema.QueryAppender

func (*QueryExprBuilder) ArrayAgg

func (b *QueryExprBuilder) ArrayAgg(builder func(ArrayAggBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Asin

func (b *QueryExprBuilder) Asin(expr any) schema.QueryAppender

func (*QueryExprBuilder) Atan

func (b *QueryExprBuilder) Atan(expr any) schema.QueryAppender

func (*QueryExprBuilder) Avg

func (b *QueryExprBuilder) Avg(builder func(AvgBuilder)) schema.QueryAppender

func (*QueryExprBuilder) AvgColumn

func (b *QueryExprBuilder) AvgColumn(column string, distinct ...bool) schema.QueryAppender

func (*QueryExprBuilder) Between

func (b *QueryExprBuilder) Between(expr, lower, upper any) schema.QueryAppender

func (*QueryExprBuilder) BitAnd

func (b *QueryExprBuilder) BitAnd(builder func(BitAndBuilder)) schema.QueryAppender

func (*QueryExprBuilder) BitOr

func (b *QueryExprBuilder) BitOr(builder func(BitOrBuilder)) schema.QueryAppender

func (*QueryExprBuilder) BoolAnd

func (b *QueryExprBuilder) BoolAnd(builder func(BoolAndBuilder)) schema.QueryAppender

func (*QueryExprBuilder) BoolOr

func (b *QueryExprBuilder) BoolOr(builder func(BoolOrBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Case

func (b *QueryExprBuilder) Case(builder func(CaseBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Ceil

func (b *QueryExprBuilder) Ceil(expr any) schema.QueryAppender

func (*QueryExprBuilder) CharLength

func (b *QueryExprBuilder) CharLength(expr any) schema.QueryAppender

func (*QueryExprBuilder) Coalesce

func (b *QueryExprBuilder) Coalesce(args ...any) schema.QueryAppender

func (*QueryExprBuilder) Column

func (b *QueryExprBuilder) Column(column string, withTableAlias ...bool) schema.QueryAppender

func (*QueryExprBuilder) Concat

func (b *QueryExprBuilder) Concat(args ...any) schema.QueryAppender

func (*QueryExprBuilder) ConcatWithSep

func (b *QueryExprBuilder) ConcatWithSep(separator any, args ...any) schema.QueryAppender

func (*QueryExprBuilder) Contains

func (b *QueryExprBuilder) Contains(expr, substr any) schema.QueryAppender

func (*QueryExprBuilder) ContainsIgnoreCase

func (b *QueryExprBuilder) ContainsIgnoreCase(expr, substr any) schema.QueryAppender

func (*QueryExprBuilder) Cos

func (*QueryExprBuilder) Count

func (b *QueryExprBuilder) Count(builder func(CountBuilder)) schema.QueryAppender

func (*QueryExprBuilder) CountAll

func (b *QueryExprBuilder) CountAll(distinct ...bool) schema.QueryAppender

func (*QueryExprBuilder) CountColumn

func (b *QueryExprBuilder) CountColumn(column string, distinct ...bool) schema.QueryAppender

func (*QueryExprBuilder) CumeDist

func (b *QueryExprBuilder) CumeDist(builder func(CumeDistBuilder)) schema.QueryAppender

func (*QueryExprBuilder) CurrentDate

func (b *QueryExprBuilder) CurrentDate() schema.QueryAppender

func (*QueryExprBuilder) CurrentTime

func (b *QueryExprBuilder) CurrentTime() schema.QueryAppender

func (*QueryExprBuilder) CurrentTimestamp

func (b *QueryExprBuilder) CurrentTimestamp() schema.QueryAppender

func (*QueryExprBuilder) DateAdd

func (b *QueryExprBuilder) DateAdd(expr, interval any, unit DateTimeUnit) schema.QueryAppender

func (*QueryExprBuilder) DateDiff

func (b *QueryExprBuilder) DateDiff(start, end any, unit DateTimeUnit) schema.QueryAppender

func (*QueryExprBuilder) DateSubtract

func (b *QueryExprBuilder) DateSubtract(expr, interval any, unit DateTimeUnit) schema.QueryAppender

func (*QueryExprBuilder) DateTrunc

func (b *QueryExprBuilder) DateTrunc(unit DateTimeUnit, expr any) schema.QueryAppender

func (*QueryExprBuilder) Decode

func (b *QueryExprBuilder) Decode(args ...any) schema.QueryAppender

func (*QueryExprBuilder) DenseRank

func (b *QueryExprBuilder) DenseRank(builder func(DenseRankBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Divide

func (b *QueryExprBuilder) Divide(left, right any) schema.QueryAppender

Divide creates a division expression (left / right). To ensure consistent float results across all databases, we cast to REAL/DOUBLE/NUMERIC. This prevents integer division behavior in SQLite and PostgreSQL.

func (*QueryExprBuilder) EndsWith

func (b *QueryExprBuilder) EndsWith(expr, suffix any) schema.QueryAppender

func (*QueryExprBuilder) EndsWithIgnoreCase

func (b *QueryExprBuilder) EndsWithIgnoreCase(expr, suffix any) schema.QueryAppender

func (*QueryExprBuilder) Equals

func (b *QueryExprBuilder) Equals(left, right any) schema.QueryAppender

func (*QueryExprBuilder) ExecByDialect

func (b *QueryExprBuilder) ExecByDialect(execs DialectExecs)

ExecByDialect executes database-specific side-effect callbacks based on the current dialect.

func (*QueryExprBuilder) ExecByDialectWithErr

func (b *QueryExprBuilder) ExecByDialectWithErr(execs DialectExecsWithErr) error

ExecByDialectWithErr executes database-specific callbacks that can return an error.

func (*QueryExprBuilder) Exists

func (b *QueryExprBuilder) Exists(builder func(SelectQuery)) schema.QueryAppender

func (*QueryExprBuilder) Exp

func (*QueryExprBuilder) Expr

func (*QueryExprBuilder) Expr(expr string, args ...any) schema.QueryAppender

func (*QueryExprBuilder) ExprByDialect

func (b *QueryExprBuilder) ExprByDialect(exprs DialectExprs) schema.QueryAppender

ExprByDialect creates a cross-database compatible expression. It selects the appropriate expression builder based on the current database dialect.

func (*QueryExprBuilder) Exprs

func (*QueryExprBuilder) Exprs(exprs ...any) schema.QueryAppender

func (*QueryExprBuilder) ExprsWithSep

func (*QueryExprBuilder) ExprsWithSep(sep any, exprs ...any) schema.QueryAppender

func (*QueryExprBuilder) ExtractDay

func (b *QueryExprBuilder) ExtractDay(expr any) schema.QueryAppender

func (*QueryExprBuilder) ExtractHour

func (b *QueryExprBuilder) ExtractHour(expr any) schema.QueryAppender

func (*QueryExprBuilder) ExtractMinute

func (b *QueryExprBuilder) ExtractMinute(expr any) schema.QueryAppender

func (*QueryExprBuilder) ExtractMonth

func (b *QueryExprBuilder) ExtractMonth(expr any) schema.QueryAppender

func (*QueryExprBuilder) ExtractSecond

func (b *QueryExprBuilder) ExtractSecond(expr any) schema.QueryAppender

func (*QueryExprBuilder) ExtractYear

func (b *QueryExprBuilder) ExtractYear(expr any) schema.QueryAppender

func (*QueryExprBuilder) FirstValue

func (b *QueryExprBuilder) FirstValue(builder func(FirstValueBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Floor

func (b *QueryExprBuilder) Floor(expr any) schema.QueryAppender

func (*QueryExprBuilder) FragmentByDialect

func (b *QueryExprBuilder) FragmentByDialect(fragments DialectFragments) ([]byte, error)

FragmentByDialect executes database-specific callbacks that return query fragments.

func (*QueryExprBuilder) GreaterThan

func (b *QueryExprBuilder) GreaterThan(left, right any) schema.QueryAppender

func (*QueryExprBuilder) GreaterThanOrEqual

func (b *QueryExprBuilder) GreaterThanOrEqual(left, right any) schema.QueryAppender

func (*QueryExprBuilder) Greatest

func (b *QueryExprBuilder) Greatest(args ...any) schema.QueryAppender

func (*QueryExprBuilder) IfNull

func (b *QueryExprBuilder) IfNull(expr, defaultValue any) schema.QueryAppender

func (*QueryExprBuilder) In

func (b *QueryExprBuilder) In(expr any, values ...any) schema.QueryAppender

func (*QueryExprBuilder) IsFalse

func (b *QueryExprBuilder) IsFalse(expr any) schema.QueryAppender

func (*QueryExprBuilder) IsNotNull

func (b *QueryExprBuilder) IsNotNull(expr any) schema.QueryAppender

func (*QueryExprBuilder) IsNull

func (b *QueryExprBuilder) IsNull(expr any) schema.QueryAppender

func (*QueryExprBuilder) IsTrue

func (b *QueryExprBuilder) IsTrue(expr any) schema.QueryAppender

func (*QueryExprBuilder) JSONArray

func (b *QueryExprBuilder) JSONArray(args ...any) schema.QueryAppender

func (*QueryExprBuilder) JSONArrayAgg

func (b *QueryExprBuilder) JSONArrayAgg(builder func(JSONArrayAggBuilder)) schema.QueryAppender

func (*QueryExprBuilder) JSONArrayAppend

func (b *QueryExprBuilder) JSONArrayAppend(json, path, value any) schema.QueryAppender

func (*QueryExprBuilder) JSONContains

func (b *QueryExprBuilder) JSONContains(json, value any) schema.QueryAppender

func (*QueryExprBuilder) JSONContainsPath

func (b *QueryExprBuilder) JSONContainsPath(json, path any) schema.QueryAppender

func (*QueryExprBuilder) JSONExtract

func (b *QueryExprBuilder) JSONExtract(json, path any) schema.QueryAppender

JSONExtract extracts value from JSON at specified path.

Note: For PostgreSQL, this uses the #>> operator which returns the value as text (unquoted). This is compatible with b.ToJSON() which will correctly cast the text back to JSONB if the result is used in subsequent JSON functions (e.g. chaining JSONExtract).

func (*QueryExprBuilder) JSONInsert

func (b *QueryExprBuilder) JSONInsert(json, path, value any) schema.QueryAppender

func (*QueryExprBuilder) JSONKeys

func (b *QueryExprBuilder) JSONKeys(json any, path ...any) schema.QueryAppender

func (*QueryExprBuilder) JSONLength

func (b *QueryExprBuilder) JSONLength(json any, path ...any) schema.QueryAppender

func (*QueryExprBuilder) JSONObject

func (b *QueryExprBuilder) JSONObject(keyValues ...any) schema.QueryAppender

func (*QueryExprBuilder) JSONObjectAgg

func (b *QueryExprBuilder) JSONObjectAgg(builder func(JSONObjectAggBuilder)) schema.QueryAppender

func (*QueryExprBuilder) JSONReplace

func (b *QueryExprBuilder) JSONReplace(json, path, value any) schema.QueryAppender

func (*QueryExprBuilder) JSONSet

func (b *QueryExprBuilder) JSONSet(json, path, value any) schema.QueryAppender

func (*QueryExprBuilder) JSONType

func (b *QueryExprBuilder) JSONType(json any, path ...any) schema.QueryAppender

func (*QueryExprBuilder) JSONUnquote

func (b *QueryExprBuilder) JSONUnquote(expr any) schema.QueryAppender

func (*QueryExprBuilder) JSONValid

func (b *QueryExprBuilder) JSONValid(expr any) schema.QueryAppender

func (*QueryExprBuilder) Lag

func (b *QueryExprBuilder) Lag(builder func(LagBuilder)) schema.QueryAppender

func (*QueryExprBuilder) LastValue

func (b *QueryExprBuilder) LastValue(builder func(LastValueBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Lead

func (b *QueryExprBuilder) Lead(builder func(LeadBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Least

func (b *QueryExprBuilder) Least(args ...any) schema.QueryAppender

func (*QueryExprBuilder) Left

func (b *QueryExprBuilder) Left(expr, length any) schema.QueryAppender

func (*QueryExprBuilder) Length

func (b *QueryExprBuilder) Length(expr any) schema.QueryAppender

func (*QueryExprBuilder) LessThan

func (b *QueryExprBuilder) LessThan(left, right any) schema.QueryAppender

func (*QueryExprBuilder) LessThanOrEqual

func (b *QueryExprBuilder) LessThanOrEqual(left, right any) schema.QueryAppender

func (*QueryExprBuilder) Literal

func (b *QueryExprBuilder) Literal(value any) schema.QueryAppender

func (*QueryExprBuilder) Ln

func (*QueryExprBuilder) Log

func (b *QueryExprBuilder) Log(expr any, base ...any) schema.QueryAppender

func (*QueryExprBuilder) Lower

func (b *QueryExprBuilder) Lower(expr any) schema.QueryAppender

func (*QueryExprBuilder) Max

func (b *QueryExprBuilder) Max(builder func(MaxBuilder)) schema.QueryAppender

func (*QueryExprBuilder) MaxColumn

func (b *QueryExprBuilder) MaxColumn(column string) schema.QueryAppender

func (*QueryExprBuilder) Min

func (b *QueryExprBuilder) Min(builder func(MinBuilder)) schema.QueryAppender

func (*QueryExprBuilder) MinColumn

func (b *QueryExprBuilder) MinColumn(column string) schema.QueryAppender

func (*QueryExprBuilder) Mod

func (b *QueryExprBuilder) Mod(dividend, divisor any) schema.QueryAppender

func (*QueryExprBuilder) Multiply

func (b *QueryExprBuilder) Multiply(left, right any) schema.QueryAppender

func (*QueryExprBuilder) NTile

func (b *QueryExprBuilder) NTile(builder func(NTileBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Not

func (*QueryExprBuilder) NotBetween

func (b *QueryExprBuilder) NotBetween(expr, lower, upper any) schema.QueryAppender

func (*QueryExprBuilder) NotEquals

func (b *QueryExprBuilder) NotEquals(left, right any) schema.QueryAppender

func (*QueryExprBuilder) NotExists

func (b *QueryExprBuilder) NotExists(builder func(SelectQuery)) schema.QueryAppender

func (*QueryExprBuilder) NotIn

func (b *QueryExprBuilder) NotIn(expr any, values ...any) schema.QueryAppender

func (*QueryExprBuilder) Now

func (*QueryExprBuilder) NthValue

func (b *QueryExprBuilder) NthValue(builder func(NthValueBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Null

func (*QueryExprBuilder) NullIf

func (b *QueryExprBuilder) NullIf(expr1, expr2 any) schema.QueryAppender

func (*QueryExprBuilder) Order

func (b *QueryExprBuilder) Order(builder func(OrderBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Paren

func (b *QueryExprBuilder) Paren(expr any) schema.QueryAppender

func (*QueryExprBuilder) PercentRank

func (b *QueryExprBuilder) PercentRank(builder func(PercentRankBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Pi

func (*QueryExprBuilder) Position

func (b *QueryExprBuilder) Position(substring, str any) schema.QueryAppender

func (*QueryExprBuilder) Power

func (b *QueryExprBuilder) Power(base, exponent any) schema.QueryAppender

func (*QueryExprBuilder) Random

func (*QueryExprBuilder) Rank

func (b *QueryExprBuilder) Rank(builder func(RankBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Repeat

func (b *QueryExprBuilder) Repeat(expr, count any) schema.QueryAppender

func (*QueryExprBuilder) Replace

func (b *QueryExprBuilder) Replace(expr, search, replacement any) schema.QueryAppender

func (*QueryExprBuilder) Reverse

func (b *QueryExprBuilder) Reverse(expr any) schema.QueryAppender

func (*QueryExprBuilder) Right

func (b *QueryExprBuilder) Right(expr, length any) schema.QueryAppender

func (*QueryExprBuilder) Round

func (b *QueryExprBuilder) Round(expr any, precision ...any) schema.QueryAppender

func (*QueryExprBuilder) RowNumber

func (b *QueryExprBuilder) RowNumber(builder func(RowNumberBuilder)) schema.QueryAppender

func (*QueryExprBuilder) Sign

func (b *QueryExprBuilder) Sign(expr any) schema.QueryAppender

func (*QueryExprBuilder) Sin

func (*QueryExprBuilder) Sqrt

func (b *QueryExprBuilder) Sqrt(expr any) schema.QueryAppender

func (*QueryExprBuilder) StartsWith

func (b *QueryExprBuilder) StartsWith(expr, prefix any) schema.QueryAppender

func (*QueryExprBuilder) StartsWithIgnoreCase

func (b *QueryExprBuilder) StartsWithIgnoreCase(expr, prefix any) schema.QueryAppender

func (*QueryExprBuilder) StdDev

func (b *QueryExprBuilder) StdDev(builder func(StdDevBuilder)) schema.QueryAppender

func (*QueryExprBuilder) StringAgg

func (b *QueryExprBuilder) StringAgg(builder func(StringAggBuilder)) schema.QueryAppender

func (*QueryExprBuilder) SubQuery

func (b *QueryExprBuilder) SubQuery(builder func(SelectQuery)) schema.QueryAppender

func (*QueryExprBuilder) SubString

func (b *QueryExprBuilder) SubString(expr, start any, length ...any) schema.QueryAppender

func (*QueryExprBuilder) Subtract

func (b *QueryExprBuilder) Subtract(left, right any) schema.QueryAppender

func (*QueryExprBuilder) Sum

func (b *QueryExprBuilder) Sum(builder func(SumBuilder)) schema.QueryAppender

func (*QueryExprBuilder) SumColumn

func (b *QueryExprBuilder) SumColumn(column string, distinct ...bool) schema.QueryAppender

func (*QueryExprBuilder) TableColumns

func (b *QueryExprBuilder) TableColumns(withTableAlias ...bool) schema.QueryAppender

func (*QueryExprBuilder) Tan

func (*QueryExprBuilder) ToBool

func (b *QueryExprBuilder) ToBool(expr any) schema.QueryAppender

func (*QueryExprBuilder) ToDate

func (b *QueryExprBuilder) ToDate(expr any, format ...any) schema.QueryAppender

func (*QueryExprBuilder) ToDecimal

func (b *QueryExprBuilder) ToDecimal(expr any, precision ...any) schema.QueryAppender

func (*QueryExprBuilder) ToFloat

func (b *QueryExprBuilder) ToFloat(expr any) schema.QueryAppender

func (*QueryExprBuilder) ToInteger

func (b *QueryExprBuilder) ToInteger(expr any) schema.QueryAppender

func (*QueryExprBuilder) ToJSON

func (b *QueryExprBuilder) ToJSON(expr any) schema.QueryAppender

func (*QueryExprBuilder) ToString

func (b *QueryExprBuilder) ToString(expr any) schema.QueryAppender

func (*QueryExprBuilder) ToTime

func (b *QueryExprBuilder) ToTime(expr any, format ...any) schema.QueryAppender

func (*QueryExprBuilder) ToTimestamp

func (b *QueryExprBuilder) ToTimestamp(expr any, format ...any) schema.QueryAppender

func (*QueryExprBuilder) Trim

func (b *QueryExprBuilder) Trim(expr any) schema.QueryAppender

func (*QueryExprBuilder) TrimLeft

func (b *QueryExprBuilder) TrimLeft(expr any) schema.QueryAppender

func (*QueryExprBuilder) TrimRight

func (b *QueryExprBuilder) TrimRight(expr any) schema.QueryAppender

func (*QueryExprBuilder) Trunc

func (b *QueryExprBuilder) Trunc(expr any, precision ...any) schema.QueryAppender

func (*QueryExprBuilder) Upper

func (b *QueryExprBuilder) Upper(expr any) schema.QueryAppender

func (*QueryExprBuilder) Variance

func (b *QueryExprBuilder) Variance(builder func(VarianceBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinArrayAgg

func (b *QueryExprBuilder) WinArrayAgg(builder func(WindowArrayAggBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinAvg

func (b *QueryExprBuilder) WinAvg(builder func(WindowAvgBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinBitAnd

func (b *QueryExprBuilder) WinBitAnd(builder func(WindowBitAndBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinBitOr

func (b *QueryExprBuilder) WinBitOr(builder func(WindowBitOrBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinBoolAnd

func (b *QueryExprBuilder) WinBoolAnd(builder func(WindowBoolAndBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinBoolOr

func (b *QueryExprBuilder) WinBoolOr(builder func(WindowBoolOrBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinCount

func (b *QueryExprBuilder) WinCount(builder func(WindowCountBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinJSONArrayAgg

func (b *QueryExprBuilder) WinJSONArrayAgg(builder func(WindowJSONArrayAggBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinJSONObjectAgg

func (b *QueryExprBuilder) WinJSONObjectAgg(builder func(WindowJSONObjectAggBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinMax

func (b *QueryExprBuilder) WinMax(builder func(WindowMaxBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinMin

func (b *QueryExprBuilder) WinMin(builder func(WindowMinBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinStdDev

func (b *QueryExprBuilder) WinStdDev(builder func(WindowStdDevBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinStringAgg

func (b *QueryExprBuilder) WinStringAgg(builder func(WindowStringAggBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinSum

func (b *QueryExprBuilder) WinSum(builder func(WindowSumBuilder)) schema.QueryAppender

func (*QueryExprBuilder) WinVariance

func (b *QueryExprBuilder) WinVariance(builder func(WindowVarianceBuilder)) schema.QueryAppender

type RankBuilder

type RankBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]
}

RankBuilder defines the RANK() window function builder.

type RawColumnDef

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

RawColumnDef stores a column definition for model-less table creation.

type RawQuery

type RawQuery interface {
	QueryExecutor
}

RawQuery executes raw SQL queries with parameter binding.

type ReferenceAction

type ReferenceAction int

ReferenceAction specifies the referential action for foreign key constraints.

const (
	ReferenceCascade    ReferenceAction = iota // CASCADE
	ReferenceRestrict                          // RESTRICT
	ReferenceSetNull                           // SET NULL
	ReferenceSetDefault                        // SET DEFAULT
	ReferenceNoAction                          // NO ACTION
)

func (ReferenceAction) String

func (r ReferenceAction) String() string

type RelationSpec

type RelationSpec struct {
	// Model is the related model to join (e.g., (*User)(nil))
	Model any
	// Alias is the table alias for the joined model.
	// If empty, defaults to the model's default alias from table metadata.
	Alias string
	// JoinType specifies the type of JOIN operation (INNER, LEFT, RIGHT).
	// If not specified (JoinDefault), defaults to LEFT JOIN.
	JoinType JoinType
	// ForeignColumn is the column in the main table that references the joined table.
	// If empty, automatically resolves to "{model_name}_{primary_key}".
	// Example: For a User model with pk "id", defaults to "user_id".
	ForeignColumn string
	// ReferencedColumn is the column in the joined table being referenced.
	// If empty, defaults to the primary key of the joined model.
	ReferencedColumn string
	// SelectedColumns specifies which columns to select from the joined table.
	// Use ColumnInfo to configure column aliases and auto-prefixing to avoid name conflicts.
	SelectedColumns []ColumnInfo
	// On is an optional function to add custom conditions to the JOIN clause.
	// The basic equality condition (foreign_key = referenced_key) is applied automatically.
	// Use this for additional filters like soft delete checks or status conditions.
	// Example: func(cb ConditionBuilder) { cb.Equals("status", "active") }
	On ApplyFunc[ConditionBuilder]
}

RelationSpec specifies how to join a related model using automatic column resolution. It provides a declarative way to define JOIN operations between models with minimal configuration. The spec automatically resolves foreign keys and primary keys based on model metadata and naming conventions.

type Returnable

type Returnable[T Executor] interface {
	// Returning adds specific columns to the RETURNING clause.
	Returning(columns ...string) T
	// ReturningAll adds all columns to the RETURNING clause (RETURNING *).
	ReturningAll() T
	// ReturningNone removes all RETURNING clauses, suppressing any auto-generated ones.
	ReturningNone() T
}

Returnable defines RETURNING clause methods for INSERT, UPDATE, and DELETE queries.

type RowNumberBuilder

type RowNumberBuilder interface {
	WindowPartitionable[WindowFrameablePartitionBuilder]
}

RowNumberBuilder defines the ROW_NUMBER() window function builder.

type SelectQuery

type SelectQuery interface {
	QueryBuilder
	SelectQueryExecutor
	DBAccessor
	CTE[SelectQuery]
	Selectable[SelectQuery]
	TableSource[SelectQuery]
	JoinOperations[SelectQuery]
	Filterable[SelectQuery]
	Orderable[SelectQuery]
	Limitable[SelectQuery]
	Applier[SelectQuery]

	// SelectAs adds a column with an alias to the SELECT clause.
	SelectAs(column, alias string) SelectQuery
	// SelectModelColumns selects the model's columns. This is the default if no select methods are called.
	SelectModelColumns() SelectQuery
	// SelectModelPKs selects only the model's primary key columns.
	SelectModelPKs() SelectQuery
	// SelectExpr adds a SQL expression to the SELECT clause with an optional alias.
	SelectExpr(builder func(ExprBuilder) any, alias ...string) SelectQuery
	// Distinct adds DISTINCT to the SELECT clause to eliminate duplicate rows.
	Distinct() SelectQuery
	// DistinctOnColumns adds DISTINCT ON for specific columns (PostgreSQL only).
	DistinctOnColumns(columns ...string) SelectQuery
	// DistinctOnExpr adds DISTINCT ON using a SQL expression (PostgreSQL only).
	DistinctOnExpr(builder func(ExprBuilder) any) SelectQuery
	// JoinRelations applies RelationSpec configurations for declarative JOIN operations.
	JoinRelations(specs ...*RelationSpec) SelectQuery
	// Relation adds a Bun relation by name with optional query customization.
	Relation(name string, apply ...func(query SelectQuery)) SelectQuery
	// GroupBy adds GROUP BY clauses for the specified columns.
	GroupBy(columns ...string) SelectQuery
	// GroupByExpr adds a GROUP BY clause using a SQL expression.
	GroupByExpr(func(ExprBuilder) any) SelectQuery
	// Having adds a HAVING condition for filtering grouped results.
	Having(func(ConditionBuilder)) SelectQuery
	// Offset sets the number of rows to skip before returning results.
	Offset(offset int) SelectQuery
	// Paginate applies LIMIT and OFFSET from a Pageable (page number + page size).
	Paginate(pageable page.Pageable) SelectQuery
	// ForShare acquires a shared lock on the selected rows (allows concurrent reads).
	ForShare(tables ...any) SelectQuery
	// ForShareNoWait acquires a shared lock, returning an error immediately if the rows are locked.
	ForShareNoWait(tables ...any) SelectQuery
	// ForShareSkipLocked acquires a shared lock, skipping rows that are currently locked.
	ForShareSkipLocked(tables ...any) SelectQuery
	// ForKeyShare acquires a key-share lock that permits concurrent SELECT FOR SHARE but blocks modifications.
	ForKeyShare(tables ...any) SelectQuery
	// ForKeyShareNoWait acquires a key-share lock, returning an error immediately if the rows are locked.
	ForKeyShareNoWait(tables ...any) SelectQuery
	// ForKeyShareSkipLocked acquires a key-share lock, skipping rows that are currently locked.
	ForKeyShareSkipLocked(tables ...any) SelectQuery
	// ForUpdate acquires an exclusive lock on the selected rows (blocks reads and writes).
	ForUpdate(tables ...any) SelectQuery
	// ForUpdateNoWait acquires an exclusive lock, returning an error immediately if the rows are locked.
	ForUpdateNoWait(tables ...any) SelectQuery
	// ForUpdateSkipLocked acquires an exclusive lock, skipping rows that are currently locked.
	ForUpdateSkipLocked(tables ...any) SelectQuery
	// ForNoKeyUpdate acquires a lock that blocks other FOR UPDATE but allows FOR KEY SHARE.
	ForNoKeyUpdate(tables ...any) SelectQuery
	// ForNoKeyUpdateNoWait acquires a no-key-update lock, returning an error immediately if the rows are locked.
	ForNoKeyUpdateNoWait(tables ...any) SelectQuery
	// ForNoKeyUpdateSkipLocked acquires a no-key-update lock, skipping rows that are currently locked.
	ForNoKeyUpdateSkipLocked(tables ...any) SelectQuery
	// Union combines results with another SELECT, eliminating duplicates.
	Union(func(query SelectQuery)) SelectQuery
	// UnionAll combines results with another SELECT, keeping all duplicates.
	UnionAll(func(query SelectQuery)) SelectQuery
	// Intersect returns only rows present in both SELECT results, eliminating duplicates.
	Intersect(func(query SelectQuery)) SelectQuery
	// IntersectAll returns only rows present in both SELECT results, keeping duplicates.
	IntersectAll(func(query SelectQuery)) SelectQuery
	// Except returns rows from this SELECT that are not in the other, eliminating duplicates.
	Except(func(query SelectQuery)) SelectQuery
	// ExceptAll returns rows from this SELECT that are not in the other, keeping duplicates.
	ExceptAll(func(query SelectQuery)) SelectQuery
}

SelectQuery builds and executes SELECT queries with support for joins, conditions, ordering, grouping, pagination, locking, and set operations.

type SelectQueryExecutor

type SelectQueryExecutor interface {
	QueryExecutor

	// Rows executes the query and returns the raw sql.Rows iterator.
	Rows(ctx context.Context) (*sql.Rows, error)
	// ScanAndCount executes the query, scans result rows into dest, and returns the total count (ignoring LIMIT/OFFSET).
	ScanAndCount(ctx context.Context, dest ...any) (int64, error)
	// Count executes a COUNT(*) query, ignoring any column selections.
	Count(ctx context.Context) (int64, error)
	// Exists returns true if the query yields at least one row.
	Exists(ctx context.Context) (bool, error)
}

SelectQueryExecutor extends QueryExecutor with SELECT-specific operations.

type Selectable

type Selectable[T Executor] interface {
	// SelectAll selects all columns (SELECT *).
	SelectAll() T
	// Select adds specific columns to the SELECT clause with automatic table alias resolution.
	Select(columns ...string) T
	// Exclude removes specific columns from the model's default column set.
	Exclude(columns ...string) T
	// ExcludeAll removes all model columns from the SELECT clause, useful when only selecting expressions.
	ExcludeAll() T
}

Selectable defines column selection methods (include/exclude).

type StatisticalAggregate

type StatisticalAggregate[T any] interface {
	// Population configures the aggregate to use population statistics (e.g., STDDEV_POP).
	Population() T
	// Sample configures the aggregate to use sample statistics (e.g., STDDEV_SAMP).
	Sample() T
}

StatisticalAggregate defines aggregate functions that support statistical modes.

type StatisticalMode

type StatisticalMode int

StatisticalMode selects the statistical variant for aggregates.

const (
	StatisticalDefault    StatisticalMode = iota
	StatisticalPopulation                 // POP
	StatisticalSample                     // SAMP
)

func (StatisticalMode) String

func (s StatisticalMode) String() string

type StdDevBuilder

type StdDevBuilder interface {
	BaseAggregate[StdDevBuilder]
	StatisticalAggregate[StdDevBuilder]
}

StdDevBuilder defines the STDDEV aggregate function builder.

type StringAggBuilder

type StringAggBuilder interface {
	BaseAggregate[StringAggBuilder]
	DistinctableAggregate[StringAggBuilder]
	OrderableAggregate[StringAggBuilder]
	NullHandlingBuilder[StringAggBuilder]

	// Separator sets the delimiter string between concatenated values.
	Separator(separator string) StringAggBuilder
}

StringAggBuilder defines the STRING_AGG aggregate function builder.

type SumBuilder

type SumBuilder interface {
	BaseAggregate[SumBuilder]
	DistinctableAggregate[SumBuilder]
}

SumBuilder defines the SUM aggregate function builder.

type TableSource

type TableSource[T Executor] interface {
	// Model sets the primary table with automatic name and alias resolution from model structure.
	Model(model any) T
	// ModelTable overrides the table name and alias resolved by Model. Must be called after Model.
	ModelTable(name string, alias ...string) T
	// Table sets the table by raw name with optional alias.
	Table(name string, alias ...string) T
	// TableFrom auto-resolves table name and alias from model. The alias parameter takes precedence.
	TableFrom(model any, alias ...string) T
	// TableExpr sets the table source to a SQL expression with optional alias.
	TableExpr(builder func(ExprBuilder) any, alias ...string) T
	// TableSubQuery sets the table source to a subquery with optional alias.
	TableSubQuery(builder func(query SelectQuery), alias ...string) T
}

TableSource defines methods for specifying table sources. Supports model-based and raw table references with optional aliases.

type TableTarget

type TableTarget[T Executor] interface {
	// Model sets the target table from a model struct with automatic name resolution.
	Model(model any) T
	// Table sets the target table by raw name(s).
	Table(tables ...string) T
}

TableTarget defines table targeting methods for DDL queries.

type TruncateTableQuery

type TruncateTableQuery interface {
	Executor
	TableTarget[TruncateTableQuery]

	// ContinueIdentity preserves the current sequence values (default behavior, opposite of RESTART IDENTITY).
	ContinueIdentity() TruncateTableQuery
	// Cascade automatically truncates dependent tables via foreign key references.
	Cascade() TruncateTableQuery
	// Restrict refuses to truncate if other tables reference this one via foreign keys.
	Restrict() TruncateTableQuery
}

TruncateTableQuery builds and executes TRUNCATE TABLE queries.

type Tx

type Tx interface {
	DB
	// Commit commits the transaction.
	Commit() error
	// Rollback aborts the transaction and discards all changes.
	Rollback() error
}

Tx extends DB with Commit and Rollback for manual transaction control.

type UniqueBuilder

type UniqueBuilder interface {
	// Name sets an explicit constraint name.
	// SQL: CONSTRAINT "name" UNIQUE (...)
	Name(name string) UniqueBuilder
	// Columns sets the columns that form the unique constraint.
	Columns(columns ...string) UniqueBuilder
}

UniqueBuilder provides a fluent API for defining table-level UNIQUE constraints.

type UniqueDef

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

UniqueDef holds the definition of a unique constraint.

func (*UniqueDef) Columns

func (u *UniqueDef) Columns(columns ...string) UniqueBuilder

func (*UniqueDef) Name

func (u *UniqueDef) Name(name string) UniqueBuilder

type UpdateAutoColumnPlanItem

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

type UpdateColumnHandler

type UpdateColumnHandler interface {
	InsertColumnHandler
	// OnUpdate sets the column value automatically when an existing row is updated.
	OnUpdate(query *BunUpdateQuery, table *schema.Table, field *schema.Field, model any, value reflect.Value)
}

UpdateColumnHandler manages columns during both insert and update operations.

type UpdateQuery

type UpdateQuery interface {
	QueryBuilder
	QueryExecutor
	DBAccessor
	CTE[UpdateQuery]
	TableSource[UpdateQuery]
	Selectable[UpdateQuery]
	Filterable[UpdateQuery]
	Orderable[UpdateQuery]
	Limitable[UpdateQuery]
	ColumnUpdatable[UpdateQuery]
	Returnable[UpdateQuery]
	Applier[UpdateQuery]

	// Set is an alias for Column.
	Set(name string, value any) UpdateQuery
	// SetExpr is an alias for ColumnExpr.
	SetExpr(name string, builder func(ExprBuilder) any) UpdateQuery
	// OmitZero skips zero-value fields when building SET clauses from the model.
	OmitZero() UpdateQuery
	// Bulk enables bulk update mode, generating a single query to update multiple rows via CTE.
	Bulk() UpdateQuery
}

UpdateQuery builds and executes UPDATE queries. Does not inherit JoinOperations; use From methods for PostgreSQL-style FROM clause.

type UpdatedAtHandler

type UpdatedAtHandler struct{}

UpdatedAtHandler sets updated_at timestamps on insert and update.

func (*UpdatedAtHandler) Name

func (*UpdatedAtHandler) Name() string

func (*UpdatedAtHandler) OnInsert

func (*UpdatedAtHandler) OnInsert(_ *BunInsertQuery, _ *schema.Table, _ *schema.Field, _ any, value reflect.Value)

func (*UpdatedAtHandler) OnUpdate

func (ua *UpdatedAtHandler) OnUpdate(query *BunUpdateQuery, _ *schema.Table, _ *schema.Field, _ any, value reflect.Value)

type UpdatedByHandler

type UpdatedByHandler struct{}

UpdatedByHandler sets updated_by using the current operator on insert and update.

func (*UpdatedByHandler) Name

func (*UpdatedByHandler) Name() string

func (*UpdatedByHandler) OnInsert

func (ub *UpdatedByHandler) OnInsert(query *BunInsertQuery, _ *schema.Table, _ *schema.Field, _ any, value reflect.Value)

func (*UpdatedByHandler) OnUpdate

func (ub *UpdatedByHandler) OnUpdate(query *BunUpdateQuery, _ *schema.Table, _ *schema.Field, _ any, _ reflect.Value)

type VarianceBuilder

type VarianceBuilder interface {
	BaseAggregate[VarianceBuilder]
	StatisticalAggregate[VarianceBuilder]
}

VarianceBuilder defines the VARIANCE aggregate function builder.

type WindowAvgBuilder

WindowAvgBuilder defines AVG() as window function builder.

type WindowBitAndBuilder

WindowBitAndBuilder defines BIT_AND() as window function builder.

type WindowBitOrBuilder

WindowBitOrBuilder defines BIT_OR() as window function builder.

type WindowBoolAndBuilder

WindowBoolAndBuilder defines BOOL_AND() as window function builder.

type WindowBoolOrBuilder

WindowBoolOrBuilder defines BOOL_OR() as window function builder.

type WindowBoundable

type WindowBoundable[T any] interface {
	// CurrentRow sets the boundary to the current row.
	CurrentRow() T
	// Preceding sets the boundary to N rows before the current row.
	Preceding(n int) T
	// Following sets the boundary to N rows after the current row.
	Following(n int) T
}

WindowBoundable defines window frame boundaries.

type WindowCountBuilder

type WindowCountBuilder interface {
	BaseAggregate[WindowCountBuilder]
	DistinctableAggregate[WindowCountBuilder]
	WindowPartitionable[WindowFrameablePartitionBuilder]

	// All configures COUNT(*) semantics for the window function.
	All() WindowCountBuilder
}

WindowCountBuilder defines COUNT() as window function builder.

type WindowEndBoundable

type WindowEndBoundable[T any] interface {
	WindowStartBoundable[T]

	// UnboundedFollowing sets the end boundary to the last row of the partition.
	UnboundedFollowing() T
}

WindowEndBoundable defines window frame end boundaries.

type WindowFrameBuilder

type WindowFrameBuilder interface {
	WindowStartBoundable[WindowFrameBuilder]

	// And switches to configuring the end boundary for BETWEEN ... AND ... syntax.
	And() WindowFrameEndBuilder
}

WindowFrameBuilder defines the window frame builder interface.

type WindowFrameEndBuilder

type WindowFrameEndBuilder interface {
	WindowEndBoundable[WindowFrameEndBuilder]
}

WindowFrameEndBuilder defines the window frame end boundary builder interface.

type WindowFrameablePartitionBuilder

type WindowFrameablePartitionBuilder interface {
	BaseWindowPartitionBuilder[WindowFrameablePartitionBuilder]
	// Rows configures a ROWS frame clause.
	Rows() WindowFrameBuilder
	// Range configures a RANGE frame clause.
	Range() WindowFrameBuilder
	// Groups configures a GROUPS frame clause.
	Groups() WindowFrameBuilder
}

WindowFrameablePartitionBuilder defines window functions that support partitioning and frame specification.

type WindowJSONArrayAggBuilder

WindowJSONArrayAggBuilder defines JSON_ARRAY_AGG() as window function builder.

type WindowJSONObjectAggBuilder

type WindowJSONObjectAggBuilder interface {
	BaseAggregate[WindowJSONObjectAggBuilder]
	DistinctableAggregate[WindowJSONObjectAggBuilder]
	OrderableAggregate[WindowJSONObjectAggBuilder]
	WindowPartitionable[WindowFrameablePartitionBuilder]

	// KeyColumn specifies the column to use as JSON object keys.
	KeyColumn(column string) WindowJSONObjectAggBuilder
	// KeyExpr specifies a raw expression to use as JSON object keys.
	KeyExpr(expr any) WindowJSONObjectAggBuilder
}

WindowJSONObjectAggBuilder defines JSON_OBJECT_AGG() as window function builder.

type WindowMaxBuilder

WindowMaxBuilder defines MAX() as window function builder.

type WindowMinBuilder

WindowMinBuilder defines MIN() as window function builder.

type WindowPartitionBuilder

type WindowPartitionBuilder interface {
	BaseWindowPartitionBuilder[WindowPartitionBuilder]
}

WindowPartitionBuilder defines the window partition builder interface.

type WindowPartitionable

type WindowPartitionable[T any] interface {
	// Over starts configuring the OVER clause for the window function.
	Over() T
}

WindowPartitionable defines window functions that support partitioning.

type WindowStartBoundable

type WindowStartBoundable[T any] interface {
	WindowBoundable[T]

	// UnboundedPreceding sets the start boundary to the first row of the partition.
	UnboundedPreceding() T
}

WindowStartBoundable defines window frame start boundaries.

type WindowStdDevBuilder

WindowStdDevBuilder defines STDDEV() as window function builder.

type WindowStringAggBuilder

WindowStringAggBuilder defines STRING_AGG() as window function builder.

type WindowSumBuilder

WindowSumBuilder defines SUM() as window function builder.

type WindowVarianceBuilder

WindowVarianceBuilder defines VARIANCE() as window function builder.

Jump to

Keyboard shortcuts

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