Help us shape the future of Go! Take the 2026 Go Developer Survey

rows

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 24 Imported by: 0

README

Joins and model scopes

As[Tag](query, alias) names one model occurrence. Use distinct tag types and SQL names for each occurrence, including self joins. Aliases preserve filters, order, limits, offsets and lazy model scopes inside their original SELECT boundary.

InnerJoin, LeftJoin, RightJoin and FullJoin take On(left, right) with matching concrete key/value types and the exact left and right input scopes. CrossJoin has no ON condition. A join chain goes on the left; the right input is one alias. Duplicate alias names or tag identities fail before execution. Each join kind has a distinct scope type. Join validation uses the SQL and alias metadata returned together by the source getter. Promoting a join marker from another embedded value cannot grant join access to an unwrapped SELECT. Outer SELECT clauses require an As boundary; unknown source shapes fail before SQL.

u := rows.As[userSide](Users.Query(), "u")
o := rows.As[orderSide](Orders.Query(), "o")
j := rows.LeftJoin(u, o, rows.On(
    expr.At(rows.Scope(u), orm.KeyExpr(Users.ID)),
    expr.At(rows.Scope(o), orm.ColumnExpr(Orders.BuyerID)),
))
userEmail := expr.At(rows.LeftScope(j, rows.Scope(u)), orm.TextExpr(Users.Email))
orderID := expr.AtNullable(rows.NullableRightScope(j, rows.Scope(o)), orm.KeyExpr(Orders.ID))
// Map orderID to a declared value.Nullable[model.ID[Order]] row field.

LeftScope and RightScope preserve non-nullable sides. Left joins require NullableRightScope; right joins require NullableLeftScope; full joins require both. expr.AtNullable widens a required column. expr.AtNullableValue keeps one nullable layer for an already nullable column. Both retain present-value comparisons and nullable selected results. expr.At accepts only preserved scopes. Use LeftNullableScope(chain, nullableScope) to retain an earlier nullable side through another join. Nullable scopes cannot convert to preserved scopes.

rows.Select maps complete declared rows. Its mappings, predicates and orders must use the resulting join scope. References to another declaration with the same Go model or another alias with the same tag fail validation before SQL. A NULL from an outer join decodes as value.Null, never a Go zero value.

ON conditions

OnEqual, OnNotEqual, ordered comparisons, nullable ordered variants, OnLike, OnLikeNullable, OnDistinctFrom and OnNotDistinctFrom accept row-phase orm/expr values. Their operands retain independent left and right scopes and exact result types. Nullable values require matching nullable operands, including explicit expr.NullableRow widening when needed. Selected aggregates cannot enter ON comparisons. expr.OrderedScalar reuses the expression package's ordered constraint; enums retain the existing row-expression capability rules.

OnAnd, OnOr and Not combine conditions without erasing either side. WhereLeft and WhereRight add predicates to ON, with the corresponding side's scope. On outer joins, those filters preserve unmatched rows. A WHERE filter on the resulting join can remove those rows. Conditions and derived filter lists are immutable, and the shared compiler bounds nested SQL and parameters.

Independent subqueries

From(modelQuery) and FromRows(projectedQuery) adapt ordinary queries without adding Query methods. They retain source filters, windows, deferred declaration checks and model scopes. Input and Scalar implement SelectionSource for projections and subqueries, but do not implement the join Source interface. Use As on a model query to join its filtered or limited SELECT through an alias boundary. Passing either adapter directly to a join is a compile error. Locked queries require LockedRecord and the explicit transaction source family.

outer := rows.From(Users.Query())
inner := rows.SelectScalar(
    rows.From(Orders.Query().OrderBy(orm.NumberDesc(Orders.TotalCents)).Limit(1)),
    expr.AsSelected(expr.Value(orm.NumberExpr(Orders.TotalCents))),
)
amount := expr.AsSelected(rows.ScalarRowQuery(outer, inner))
// Map amount with rows.MapSelected to a value.Nullable[int64] row field.

SelectScalar accepts one selected expression, including an aggregate. Its Scalar[S,V] descriptor is not executable and cannot be made from a general projected record. WhereScalar adds row predicates with the descriptor's source scope. Existing SelectValue remains unchanged for direct scalar reads.

ScalarRowQuery widens an independent scalar's result to value.Nullable[V]. No rows becomes SQL NULL; multiple rows produce PostgreSQL cardinality error 21000. The API adds no implicit LIMIT. ScalarNullableRowQuery retains one existing nullable layer. Passing already nullable input to ScalarRowQuery fails validation, as with expr.Nullable. Both constructors produce row expressions for comparisons or arithmetic; call expr.AsSelected to use the same result in a selected phase. An aggregate inside that SELECT stays in the inner phase.

InQuery(rowValue, scalar) requires matching exact types, including nullability. InNullableQuery explicitly admits nullable inner values. Neither filters NULLs nor replaces them with zero values. expr.Not retains SQL's three-valued NOT IN semantics. ExistsQuery(outer, inner) accepts model, projected, alias, join and scalar sources; it retains inner selections, aggregate phases and windows, including LIMIT zero. It anchors the predicate to the exact outer declaration. Independent subqueries do not admit outer references; use the explicit correlation descriptors below.

All these operations use the existing querycore.Subquery and SubqueryPredicate compiler shared by relation EXISTS. Deferred source checks run before execution, and all nested SELECTs share compiler depth, node, parameter and SQL-size limits. PostgreSQL FULL JOIN conditions retain its planner restrictions.

Correlation and LATERAL

Correlate(outer, inner) binds an inner SELECT to a declared enclosing scope. Use From for model queries, ModelScope for their model fields, or rows.As/rows.Scope for aliases. OuterScope and InnerScope lift fields into Correlation[Outer,Inner]; the nullable variants retain outer-join nullability. A containing CorrelatedSource can serve as the outer scope of another correlation. Only its visible ancestors and local sources become visible. Distinct SQL names are required: inner sources cannot shadow enclosing sources.

parent := rows.As[parentSide](Users.Query(), "parent")
child := rows.As[childSide](Orders.Query(), "child")
link := rows.Correlate(parent, child)
parentID := expr.At(rows.OuterScope(link, rows.Scope(parent)), orm.KeyExpr(Users.ID))
childScope := rows.InnerScope(link, rows.Scope(child))
buyerID := expr.At(childScope, orm.ColumnExpr(Orders.BuyerID))
link = link.Where(expr.Equal(buyerID, parentID))
record := rows.SelectCorrelatedRecord(link, childScope).
    OrderBy(expr.Desc(expr.At(childScope, orm.NumberExpr(Orders.TotalCents)))).Limit(1)
latest := rows.AsLateral[latestSide](record, "latest")
joined := rows.LeftJoinLateral(parent, latest)
amount := expr.AtNullable(
    rows.NullableRightScope(joined, rows.LateralScope(latest)), orm.NumberExpr(Orders.TotalCents))
// Map amount into a declared value.Nullable[int64] row field.

SelectCorrelatedScalar accepts a lifted selected expression. Consume it with CorrelatedScalarRowQuery, its nullable counterpart, InCorrelatedQuery, InNullableCorrelatedQuery, or Exists. Missing scalar rows become NULL; multiple rows remain a database cardinality error. Inner aggregates stay in their own SELECT. Correlated descriptors have Where, OrderBy, Limit, Offset and Exists, with no independent execution or ordinary-source conversion.

SelectCorrelatedRecord selects one complete preserved inner model. ProjectCorrelated uses the existing row schema and complete mapping validation for a declared result. AsLateral always retains that record inside a derived SELECT. It grants no ordinary join or execution capability. CrossJoinLateral, InnerJoinLateral and LeftJoinLateral require the exact preceding outer scope; right/full lateral joins are excluded. Inner/left joins accept optional typed ON conditions, defaulting to ON TRUE. Left joins preserve parents when ON rejects a record or the inner SELECT is empty, and require nullable right scopes.

For a declared projection result, use rows.At(scope, Schema.Field) to read its column with its original value codec. rows.AtNullable widens a required field; rows.AtNullableValue retains one nullable layer. Model results continue to use expr.At and its nullable variants. Both paths validate the declaration identity, including declarations with identical Go types and SQL names.

Visibility, grouping rules, lateral ordering, bound SQL values, declaration checks and nested-query limits use the existing shared compiler. Ordinary join boundary checks also apply to the lateral parent. Transaction variants retain the lock requirement. Correlated records have no ordinary selection-source capability; use an explicit lateral join before CTE composition.

Complete record adapters

See complete records and transaction projections for ModelRecord, RecordOf, AsRecord, SelectRecord and the transaction-required record family. These adapters retain complete decoders and provide the shared foundation for CTE/set/cursor composition and transaction joins.

See CTEs, recursion and set operations for complete-record CTEs, transaction CTEs, recursive self scopes, and record/scalar set composition.

See completed-result cursors and read terminals for output scopes, keyset navigation, numbered pages and transaction-only projection locks.

See transaction composition for transaction joins, subqueries, correlation and LATERAL.

Report reads

Adapt a rows.Query[S, R] with rows.Read for collection and pagination:

q := rows.ReorderUnwindowed(report, expr.Asc(name), expr.Asc(id))
if err := rows.PreflightRead(ctx, rows.Read(q)); err != nil { return err }
total, err := rows.Read(q).Count(ctx, tx)
page, err := rows.Read(q).Paginate(ctx, tx, orm.Page(1, 20))
more, err := rows.Read(q).SimplePaginate(ctx, tx, orm.Page(1, 20))
err = rows.EachRead(ctx, tx, rows.Read(rows.Limit(q, 10001)), writeCSV)

rows.CompileRead(rows.Read(q)) returns an immutable orm.Statement for inspection. rows.PreflightRead uses the executing request context, resolving context scopes without opening a connection. Execution uses its own current context and the supplied executor. Result.Count wraps the complete selection, preserving grouping, HAVING, DISTINCT and existing result windows. Pagination requires explicit ordering and no outer limit/offset. Supply a unique final tie-breaker. Use a repeatable-read transaction when the count and page must share one snapshot.

ReorderUnwindowed replaces only outer ordering. It rejects outer LIMIT/OFFSET, DISTINCT ON and an empty order list; nested windows and scopes survive. rows.EachRead streams scalar/DTO results one row at a time. Complete-model reads with possible retrieval callbacks use bounded batches, closing rows before model retrieval dispatch and delivery; other complete-model reads stream. Callback errors preserve identity and stop traversal; panic, Goexit, decoding failure and cancellation close the rows. Completed batches remain delivered. See read terminals for batch and factory ownership. Exports should set their own row limit and stop on the first excess row.

Scalar SELECTs keep their subquery boundary when composed with OrderScalar, LimitScalar and OffsetScalar. These package functions also accept scalars selected from CTE aliases. Ordering accepts row and selected orders in the same scope; negative bounds and foreign declarations fail normal compile/preflight validation. No implicit limit hides scalar cardinality errors.

Use HavingCorrelatedRecord and DistinctCorrelatedRecord before AsLateral, and DistinctOnCorrelatedScalar before a correlated scalar/EXISTS operation. HAVING takes lifted group predicates; DISTINCT ON takes lifted row keys and keeps PostgreSQL's ordering validation. The resulting descriptors retain their parent, input and result types and do not acquire independent execution capabilities.

GroupByScalar and HavingScalar add row keys and group predicates within a scalar SELECT. DistinctScalar deduplicates its selected value after grouping; DistinctOnScalar takes row keys, including keys absent from the selected output. DistinctOnScalarValues accepts selected keys while retaining group/window validation. Order by the DISTINCT ON keys first. These clauses preserve the selected codec, nullability and subquery boundary. They never impose a scalar cardinality limit.

DistinctRecord, DistinctSet and DistinctValues deduplicate complete record, record-set and value-set results. They preserve inner input SELECTs and retain the ordinary read-only result family. Existing bounds and ordering remain in place; NULL equality and selected-order validation follow the shared PostgreSQL compiler.

Correlated scalar keys use GroupByCorrelatedScalar for lifted row grouping and DistinctOnCorrelatedScalarValues for selected keys. Use OrderCorrelatedScalar when ordering by aggregates or windows; its leading orders must match the DISTINCT ON keys. These functions preserve the enclosing scope and inner limit/offset.

DistinctOnValueSet accepts selected keys in the combined Set[V] scope. For example, rows.DistinctOnValueSet(values, expr.Key(expr.AsSelected(expr.Row(values.Value())))) retains the scalar codec, including nullability. Group keys cannot be substituted for selected keys, and keys from either input query cannot enter the combined scope. Both families reuse the ordinary rows clause and compiler validation.

Derived result fields can be aggregated without losing their declaration ownership: expr.SumRow(rows.At(scope, Totals.Amount)) and expr.SumNullableRow return nullable exact decimals. The float, interval, min/max and count families keep their existing result rules. Only declared ordered fields grant ordered aggregate input; enums, computed parameters and foreign declarations fail validation. The original expr.SumAt(scope, modelColumn) API remains unchanged.

DistinctOnRecord(record, keys...).OrderBy(...) keeps keys and ordering in the original input scope, including joined fields outside the selected complete record. It remains read-only and uses the shared ordering-prefix validation.

CompileCursor and PreflightCursor validate completed-output cursor keys and canonical ordering without I/O. CompileValueCursor and PreflightValueCursor provide the same boundary for scalar cursors. Compilation adds no page boundary or lookahead limit; preflight uses the executing context, including current global scopes. Invalid computed keys are rejected here, before pagination is invoked.

Documentation

Overview

Package rows provides typed aliases, joins and complete row projections. Example: rows.Select(joined,OrderRows,rows.Map(OrderRows.ID,orderID)).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func At

func At[S, R, V any](scope expr.Scope[S, R], field Field[R, V]) expr.RowExpression[S, V]

At reads a declared projection field within its named record scope. Example: rows.At(rows.LateralScope(totals),Totals.Count).

func AtNullable

func AtNullable[S, R, V any](scope expr.NullableScope[S, R], field Field[R, V]) expr.RowExpression[S, value.Nullable[V]]

AtNullable widens a required projection field from a nullable join side. Example: rows.AtNullable(rows.NullableRightScope(j,scope),Totals.Count).

func AtNullableValue

func AtNullableValue[S, R, V any](scope expr.NullableScope[S, R], field Field[R, value.Nullable[V]]) expr.RowExpression[S, value.Nullable[V]]

AtNullableValue retains one nullable layer for a nullable projection field. Example: rows.AtNullableValue(scope,Summary.Note).

func Check

func Check(schemas ...CheckedSchema) error

Check collects row startup errors. Example: rows.Check(OrderRows).

func CompileCursor

func CompileCursor[R any](q CursorQuery[R]) (orm.Statement, error)

CompileCursor validates output keys and compiles canonical ordering without I/O. It adds no page boundary or lookahead limit. Example: rows.CompileCursor(cursor).

func CompileRead

func CompileRead[S, R any](q ReadSource[S, R]) (orm.Statement, error)

CompileRead inspects an ordinary scalar, record or set read without I/O. Example: rows.CompileRead(rows.ReadScalar(selected)).

func CompileValueCursor

func CompileValueCursor[V any](q ValueCursorQuery[V]) (orm.Statement, error)

CompileValueCursor inspects a scalar cursor without a page boundary or I/O. Example: rows.CompileValueCursor(cursor).

func ConflictScalarNullableRowQuery

func ConflictScalarNullableRowQuery[M, I, V any](records ConflictRows[M], inner Scalar[I, value.Nullable[V]]) expr.RowExpression[ConflictRow[M], value.Nullable[V]]

ConflictScalarNullableRowQuery preserves one nullable layer for an independent scalar. Example: rows.ConflictScalarNullableRowQuery(records,lookup).

func ConflictScalarRowQuery

func ConflictScalarRowQuery[M, I, V any](records ConflictRows[M], inner Scalar[I, V]) expr.RowExpression[ConflictRow[M], value.Nullable[V]]

ConflictScalarRowQuery evaluates an independent scalar SELECT; no rows become NULL. Example: rows.ConflictScalarRowQuery(records,lookup).

func ConflictTargetWhere

func ConflictTargetWhere[M any](policy orm.Conflict[M], predicates ...expr.Predicate[M]) orm.Conflict[M]

ConflictTargetWhere declares a partial index predicate using fixed migration values. Example: rows.ConflictTargetWhere(policy,expr.Eq(expr.Value(orm.ColumnExpr(Users.Active)), true)).

func ConflictWhereRows

func ConflictWhereRows[M any](policy orm.Conflict[M], predicates ...expr.Predicate[ConflictRow[M]]) orm.Conflict[M]

ConflictWhereRows adds update conditions over stored and proposed records. Example: rows.ConflictWhereRows(policy,expr.Greater(proposed,stored)).

func CorrelatedScalarNullableRowQuery

func CorrelatedScalarNullableRowQuery[O, I, V any](s CorrelatedScalar[O, I, value.Nullable[V]]) expr.RowExpression[O, value.Nullable[V]]

CorrelatedScalarNullableRowQuery preserves nullable row-expression results. Example: rows.CorrelatedScalarNullableRowQuery(selected).

func CorrelatedScalarRowQuery

func CorrelatedScalarRowQuery[O, I, V any](s CorrelatedScalar[O, I, V]) expr.RowExpression[O, value.Nullable[V]]

CorrelatedScalarRowQuery exposes a correlated scalar in row expressions. Example: expr.GreaterNullable(age,rows.CorrelatedScalarRowQuery(selected)).

func Define

func Define[R any, T Schema[R]](declare func(Builder[R], *R) T) (result T)

Define binds and seals a complete row shape. Example: rows.Define(func(b rows.Builder[OrderRow],r *OrderRow) Fields {...}).

func DeleteUsing

func DeleteUsing[S, M any](destination orm.Query[M], source SelectionSource[S]) orm.DeleteSource[S, M]

DeleteUsing applies ordinary soft deletion and deduplicates source matches. Example: rows.DeleteUsing(Users.Query(),rows.From(Archives.Query())).Match(key).

func EachRead

func EachRead[S, R any](ctx context.Context, ex database.Executor, q ReadSource[S, R], yield func(R) error) error

EachRead iterates an ordinary scalar, record or set with bounded memory. Complete models with possible retrieval callbacks use DefaultChunkSize batches, closing rows before dispatch and delivery. Other results stream one row at a time. Ordering/windows and callback error identity are preserved; batches do not share a snapshot. Example: rows.EachRead(ctx, db, selectedRecord, visit).

func ExistsQuery

func ExistsQuery[S, I any](outer SelectionSource[S], inner SelectionSource[I]) expr.Predicate[S]

ExistsQuery anchors an independent SELECT's existence in the outer scope. Example: rows.ExistsQuery(rows.From(users),rows.From(orders)).

func Explain

func Explain[S, R any](ctx context.Context, ex database.Executor, q Result[S, R]) (orm.Plan, error)

Explain plans an ordinary projection, scalar or set adapted through Read. Example: rows.Explain(ctx, db, rows.Read(report)).

func ExplainAnalyze

func ExplainAnalyze[S, R any](ctx context.Context, ex database.Executor, q Result[S, R]) (orm.Plan, error)

ExplainAnalyze executes an ordinary result and reports actual measurements. Example: rows.ExplainAnalyze(ctx, db, rows.ReadSet(combined)).

func ExplainAnalyzeCursor

func ExplainAnalyzeCursor[R any](ctx context.Context, ex database.Executor, q CursorQuery[R]) (orm.Plan, error)

ExplainAnalyzeCursor executes the canonical cursor result without pagination. Example: rows.ExplainAnalyzeCursor(ctx, db, cursor).

func ExplainAnalyzeTransaction

func ExplainAnalyzeTransaction[R any](ctx context.Context, tx *database.Tx, q TransactionRecordSource[R]) (orm.Plan, error)

ExplainAnalyzeTransaction executes transaction-owned records. Example: rows.ExplainAnalyzeTransaction(ctx, tx, selected).

func ExplainAnalyzeTransactionValue

func ExplainAnalyzeTransactionValue[S, V any](ctx context.Context, tx *database.Tx, q TransactionValue[S, V]) (orm.Plan, error)

ExplainAnalyzeTransactionValue executes a transaction-owned scalar. Example: rows.ExplainAnalyzeTransactionValue(ctx, tx, selected).

func ExplainAnalyzeValueCursor

func ExplainAnalyzeValueCursor[V any](ctx context.Context, ex database.Executor, q ValueCursorQuery[V]) (orm.Plan, error)

ExplainAnalyzeValueCursor executes the canonical scalar cursor result. Example: rows.ExplainAnalyzeValueCursor(ctx, db, cursor).

func ExplainCursor

func ExplainCursor[R any](ctx context.Context, ex database.Executor, q CursorQuery[R]) (orm.Plan, error)

ExplainCursor plans a canonical completed cursor without a page boundary. Example: rows.ExplainCursor(ctx, db, cursor).

func ExplainTransaction

func ExplainTransaction[R any](ctx context.Context, tx *database.Tx, q TransactionRecordSource[R]) (orm.Plan, error)

ExplainTransaction plans records retaining nested transaction requirements. Example: rows.ExplainTransaction(ctx, tx, rows.LockedRecord(orm.Lock(Users.Query()))).

func ExplainTransactionValue

func ExplainTransactionValue[S, V any](ctx context.Context, tx *database.Tx, q TransactionValue[S, V]) (orm.Plan, error)

ExplainTransactionValue plans a transaction-owned scalar. Example: rows.ExplainTransactionValue(ctx, tx, selected).

func ExplainValueCursor

func ExplainValueCursor[V any](ctx context.Context, ex database.Executor, q ValueCursorQuery[V]) (orm.Plan, error)

ExplainValueCursor plans a canonical scalar cursor without a page boundary. Example: rows.ExplainValueCursor(ctx, db, cursor).

func ForceDeleteUsing

func ForceDeleteUsing[S, M any](destination orm.Query[M], soft orm.SoftDeletable[M], source SelectionSource[S]) orm.DeleteSource[S, M]

ForceDeleteUsing physically removes soft-delete models within the supplied visibility. Example: rows.ForceDeleteUsing(Users.Query().WithTrashed(),Users.Soft,rows.From(Archives.Query())).Match(key).

func InCorrelatedQuery

func InCorrelatedQuery[O, I, V any](v expr.RowValue[O, V], s CorrelatedScalar[O, I, V]) expr.Predicate[O]

InCorrelatedQuery requires exact enclosing scope and value type. Example: rows.InCorrelatedQuery(userID,selected).

func InNullableCorrelatedQuery

func InNullableCorrelatedQuery[O, I, V any](v expr.RowValue[O, V], s CorrelatedScalar[O, I, value.Nullable[V]]) expr.Predicate[O]

InNullableCorrelatedQuery admits nullable inner values with SQL NULL semantics. Example: rows.InNullableCorrelatedQuery(userID,nullableIDs).

func InNullableQuery

func InNullableQuery[S, I, V any](left expr.RowValue[S, V], inner Scalar[I, value.Nullable[V]]) expr.Predicate[S]

InNullableQuery explicitly admits nullable inner results without replacing NULLs. Example: rows.InNullableQuery(expr.Value(orm.KeyExpr(Users.ID)),nullableIDs).

func InQuery

func InQuery[S, I, V any](left expr.RowValue[S, V], inner Scalar[I, V]) expr.Predicate[S]

InQuery requires an exact row/result type, including nullability. Example: rows.InQuery(expr.Value(orm.KeyExpr(Users.ID)),inner).

func InnerNullableScope

func InnerNullableScope[O, I, M any](c CorrelatedSource[O, I], scope expr.NullableScope[I, M]) expr.NullableScope[Correlation[O, I], M]

InnerNullableScope preserves an inner outer join's nullability. Example: rows.InnerNullableScope(c,rows.NullableRightScope(j,scope)).

func InnerScope

func InnerScope[O, I, M any](c CorrelatedSource[O, I], scope expr.Scope[I, M]) expr.Scope[Correlation[O, I], M]

InnerScope lifts a preserved inner model into a correlation. Example: rows.InnerScope(c,rows.Scope(child)).

func InsertFrom

func InsertFrom[S, M any](source SelectionSource[S], destination orm.Query[M], mappings ...orm.InsertMapping[S, M]) orm.InsertSelect[S, M]

InsertFrom inserts the selected source window, keeping defaults and NULL for omitted fields. Example: rows.InsertFrom(rows.From(Users.Query()),Archives.Query(),mapping).

func LateralScope

func LateralScope[A, O, R any](source LateralSource[A, O, R]) expr.Scope[Alias[A, R], R]

LateralScope exposes the named complete record for ON and result mapping. Example: expr.At(rows.LateralScope(latest), orm.KeyExpr(Orders.ID)).

func LeftNullableScope

func LeftNullableScope[S, L, M any](j leftScopeSource[S, L], scope expr.NullableScope[L, M]) expr.NullableScope[S, M]

LeftNullableScope retains an already nullable scope through another join. Example: rows.LeftNullableScope(chain,nullableOrders).

func LeftScope

func LeftScope[S, L, M any](j preservedLeftSource[S, L], scope expr.Scope[L, M]) expr.Scope[S, M]

LeftScope preserves a model from the non-nullable left side. Example: rows.LeftScope(joined,rows.Scope(members)).

func MapInsert

func MapInsert[S, M, V, P any, C orm.InsertTarget[M, V, P]](field C, expression expr.RowValue[S, P]) orm.InsertMapping[S, M]

MapInsert maps an exact stored SQL value without running a mutator. Example: rows.MapInsert(orm.TextExpr(Archives.Name), expr.Value(orm.TextExpr(Users.Name))).

func MapUpdate

func MapUpdate[S, M, V, P any, C orm.UpdateTarget[M, V, P]](field C, expression expr.RowValue[S, P]) orm.UpdateMapping[S, M]

MapUpdate maps an exact stored SQL value to a non-primary field. Example: rows.MapUpdate(orm.TextExpr(Users.Name), expr.Value(orm.TextExpr(Archives.Name))).

func MatchNullableSource

func MatchNullableSource[S, M, V, P any](field orm.ExpressionColumn[M, V, P], expression expr.RowValue[S, value.Nullable[P]]) orm.SourceKey[S, M]

MatchNullableSource accepts outer-join keys; NULL matches no destination. Example: rows.MatchNullableSource(Users.ID,nullableUserID).

func MatchSource

func MatchSource[S, M, V, P any](field orm.ExpressionColumn[M, V, P], expression expr.RowValue[S, P]) orm.SourceKey[S, M]

MatchSource matches compatible stored primary values without assigning them. Example: rows.MatchSource(orm.KeyExpr(Users.ID), expr.Value(orm.ColumnExpr(Archives.UserID))).

func ModelScope

func ModelScope[M any](q orm.Query[M]) expr.Scope[M, M]

ModelScope exposes an ordinary model query's declaration. Example: rows.ModelScope(Users.Query()).

func NullableLeftScope

func NullableLeftScope[S, L, M any](j nullableLeftSource[S, L], scope expr.Scope[L, M]) expr.NullableScope[S, M]

NullableLeftScope widens the missing left rows of a right/full join. Example: rows.NullableLeftScope(joined,rows.Scope(members)).

func NullableRightScope

func NullableRightScope[S, R, M any](j nullableRightSource[S, R], scope expr.Scope[R, M]) expr.NullableScope[S, M]

NullableRightScope widens the missing right rows of a left/full join. Example: rows.NullableRightScope(joined,rows.Scope(orders)).

func OnConflictKeys

func OnConflictKeys[M any](keys ...expr.GroupKey[M]) orm.Conflict[M]

OnConflictKeys infers a unique index using row-phase expressions. Example: rows.OnConflictKeys(expr.Group(expr.Add(age,age))).

func OuterNullableScope

func OuterNullableScope[O, I, M any](c CorrelatedSource[O, I], scope expr.NullableScope[O, M]) expr.NullableScope[Correlation[O, I], M]

OuterNullableScope preserves an enclosing outer join's nullability. Example: rows.OuterNullableScope(c,rows.NullableRightScope(j,scope)).

func OuterScope

func OuterScope[O, I, M any](c CorrelatedSource[O, I], scope expr.Scope[O, M]) expr.Scope[Correlation[O, I], M]

OuterScope lifts a preserved enclosing model into a correlation. Example: rows.OuterScope(c,rows.Scope(parent)).

func PreflightCursor

func PreflightCursor[R any](ctx context.Context, q CursorQuery[R]) error

PreflightCursor validates a cursor with the executing request context and no I/O. Example: rows.PreflightCursor(ctx,cursor).

func PreflightRead

func PreflightRead[S, R any](ctx context.Context, q ReadSource[S, R]) error

PreflightRead validates an ordinary read using the executing request context. Example: rows.PreflightRead(ctx, rows.ReadSet(combined)).

func PreflightValueCursor

func PreflightValueCursor[V any](ctx context.Context, q ValueCursorQuery[V]) error

PreflightValueCursor validates a scalar cursor with the executing request context. Example: rows.PreflightValueCursor(ctx,cursor).

func Raw

func Raw[R any](ctx context.Context, ex database.Executor, schema Schema[R], sql string, args ...any) ([]R, error)

Raw hydrates exactly the schema's declared columns, matched by name in any order. It applies NO scopes and uses ex directly without read routing: raw SQL may write. Decode failure discards all results, but does not imply a write rolled back. Example: rows.Raw(ctx, tx, OrderRows, "SELECT id, label FROM orders WHERE id=$1", id).

func RightScope

func RightScope[S, R, M any](j preservedRightSource[S, R], scope expr.Scope[R, M]) expr.Scope[S, M]

RightScope preserves a model from the non-nullable right side. Example: rows.RightScope(joined,rows.Scope(orders)).

func ScalarNullableRowQuery

func ScalarNullableRowQuery[S, I, V any](outer SelectionSource[S], inner Scalar[I, value.Nullable[V]]) expr.RowExpression[S, value.Nullable[V]]

ScalarNullableRowQuery retains one nullable layer in row expressions. Example: rows.ScalarNullableRowQuery(outer,nullableInner).

func ScalarRowQuery

func ScalarRowQuery[S, I, V any](outer SelectionSource[S], inner Scalar[I, V]) expr.RowExpression[S, value.Nullable[V]]

ScalarRowQuery evaluates an independent scalar in row comparisons or arithmetic. Example: expr.GreaterNullable(age,rows.ScalarRowQuery(outer,inner)).

func Scope

func Scope[A, M any](a Aliased[A, M]) expr.Scope[Alias[A, M], M]

Scope selects the model scope of an alias. Example: expr.At(rows.Scope(members),orm.KeyExpr(Members.ID)).

func SetConflictValue

func SetConflictValue[M, V, P any](field orm.ExpressionColumn[M, V, P], calculation expr.RowValue[ConflictRow[M], P]) orm.ConflictUpdate[M]

SetConflictValue assigns an exact stored type, including nullability, from the conflict row phase. Example: rows.SetConflictValue(orm.NumberExpr(Users.Age), expr.Add(stored,proposed)).

func TransactionCorrelatedScalarNullableRowQuery

func TransactionCorrelatedScalarNullableRowQuery[O, I TransactionScopeType, V any](s TransactionCorrelatedScalar[O, I, value.Nullable[V]]) expr.RowExpression[O, value.Nullable[V]]

TransactionCorrelatedScalarNullableRowQuery preserves nullable row-expression results. Example: rows.TransactionCorrelatedScalarNullableRowQuery(selected).

func TransactionCorrelatedScalarRowQuery

func TransactionCorrelatedScalarRowQuery[O, I TransactionScopeType, V any](s TransactionCorrelatedScalar[O, I, V]) expr.RowExpression[O, value.Nullable[V]]

TransactionCorrelatedScalarRowQuery exposes a correlated scalar in row expressions. Example: expr.GreaterNullable(age,rows.TransactionCorrelatedScalarRowQuery(selected)).

func TransactionExistsQuery

func TransactionExistsQuery[S TransactionScopeType](outer TransactionSelectionSource[S], inner TransactionSubquerySource) expr.Predicate[S]

TransactionExistsQuery anchors an independent SELECT to a transaction scope. Example: rows.TransactionExistsQuery(parent,selected).

func TransactionInCorrelatedQuery

func TransactionInCorrelatedQuery[O, I TransactionScopeType, V any](v expr.RowValue[O, V], s TransactionCorrelatedScalar[O, I, V]) expr.Predicate[O]

TransactionInCorrelatedQuery requires exact enclosing scope and value type. Example: rows.TransactionInCorrelatedQuery(userID,selected).

func TransactionInNullableCorrelatedQuery

func TransactionInNullableCorrelatedQuery[O, I TransactionScopeType, V any](v expr.RowValue[O, V], s TransactionCorrelatedScalar[O, I, value.Nullable[V]]) expr.Predicate[O]

TransactionInNullableCorrelatedQuery admits nullable inner values with SQL NULL semantics. Example: rows.TransactionInNullableCorrelatedQuery(userID,nullableIDs).

func TransactionInNullableQuery

func TransactionInNullableQuery[S TransactionScopeType, V any](left expr.RowValue[S, V], inner TransactionValueSource[value.Nullable[V]]) expr.Predicate[S]

TransactionInNullableQuery explicitly admits NULL inner values. Example: rows.TransactionInNullableQuery(id,nullableIDs).

func TransactionInQuery

func TransactionInQuery[S TransactionScopeType, V any](left expr.RowValue[S, V], inner TransactionValueSource[V]) expr.Predicate[S]

TransactionInQuery requires an exact row/result type in a transaction scope. Example: rows.TransactionInQuery(id,selected).

func TransactionInnerNullableScope

func TransactionInnerNullableScope[O, I TransactionScopeType, M any](c TransactionCorrelatedSource[O, I], scope expr.NullableScope[I, M]) expr.NullableScope[TransactionCorrelation[O, I], M]

TransactionInnerNullableScope preserves an inner outer join's nullability. Example: rows.TransactionInnerNullableScope(c,rows.NullableRightScope(j,scope)).

func TransactionInnerScope

func TransactionInnerScope[O, I TransactionScopeType, M any](c TransactionCorrelatedSource[O, I], scope expr.Scope[I, M]) expr.Scope[TransactionCorrelation[O, I], M]

TransactionInnerScope lifts a preserved inner model into a correlation. Example: rows.TransactionInnerScope(c,rows.TransactionScope(child)).

func TransactionLateralScope

func TransactionLateralScope[A any, O TransactionScopeType, R any](source TransactionLateralSource[A, O, R]) expr.Scope[TransactionAlias[A, R], R]

TransactionLateralScope exposes the named complete record for ON and result mapping. Example: expr.At(rows.TransactionLateralScope(latest), orm.KeyExpr(Orders.ID)).

func TransactionOuterNullableScope

func TransactionOuterNullableScope[O, I TransactionScopeType, M any](c TransactionCorrelatedSource[O, I], scope expr.NullableScope[O, M]) expr.NullableScope[TransactionCorrelation[O, I], M]

TransactionOuterNullableScope preserves an enclosing outer join's nullability. Example: rows.TransactionOuterNullableScope(c,rows.NullableRightScope(j,scope)).

func TransactionOuterScope

func TransactionOuterScope[O, I TransactionScopeType, M any](c TransactionCorrelatedSource[O, I], scope expr.Scope[O, M]) expr.Scope[TransactionCorrelation[O, I], M]

TransactionOuterScope lifts a preserved enclosing model into a correlation. Example: rows.TransactionOuterScope(c,rows.TransactionScope(parent)).

func TransactionScalarNullableRowQuery

func TransactionScalarNullableRowQuery[S TransactionScopeType, V any](outer TransactionSelectionSource[S], inner TransactionValueSource[value.Nullable[V]]) expr.RowExpression[S, value.Nullable[V]]

TransactionScalarNullableRowQuery makes a transaction scalar available in row expressions. Example: rows.TransactionScalarNullableRowQuery(parent,selected).

func TransactionScalarRowQuery

func TransactionScalarRowQuery[S TransactionScopeType, V any](outer TransactionSelectionSource[S], inner TransactionValueSource[V]) expr.RowExpression[S, value.Nullable[V]]

TransactionScalarRowQuery makes a transaction scalar available in row expressions. Example: rows.TransactionScalarRowQuery(parent,selected).

func TransactionScope

func TransactionScope[A, R any](source TransactionAliased[A, R]) expr.Scope[TransactionAlias[A, R], R]

TransactionScope exposes preserved transaction-owned model or projection fields. Example: expr.At(rows.TransactionScope(source), orm.KeyExpr(Orders.ID)).

func UpdateFrom

func UpdateFrom[S, M any](destination orm.Query[M], source SelectionSource[S]) orm.UpdateSource[S, M]

UpdateFrom preserves source windows and destination scopes independently. Example: rows.UpdateFrom(Users.Query(),rows.From(Archives.Query())).Match(key).

Types

type Alias

type Alias[A, M any] struct {
	// contains filtered or unexported fields
}

Alias gives each model occurrence a distinct scope. Example: Alias[memberSide,Member].

type Aliased

type Aliased[A, M any] struct {
	// contains filtered or unexported fields
}

Aliased is a model source with one typed alias. Example: rows.As[memberSide](Members.Query(),"members").

func As

func As[A, M any](q orm.Query[M], alias string) Aliased[A, M]

As aliases a model query, preserving its filters and soft-delete scope. Example: members := rows.As[memberSide](Members.Query(),"members").

func AsRecord

func AsRecord[A, R any](source RecordSource[R], alias string) Aliased[A, R]

AsRecord aliases a complete model/projection while retaining its SELECT boundary. Example: rows.AsRecord[summaryTag](rows.RecordOf(report),"summary").

type Annotated

type Annotated[M, V any] struct {
	Model M
	Value V
	// contains filtered or unexported fields
}

Annotated pairs a complete hydrated model with a computed value from its row. Example: item.Model.Name and item.Value from rows.WithValue.

type Builder

type Builder[R any] struct {
	// contains filtered or unexported fields
}

Builder binds result fields at startup. Example: rows.NumberOf(b,&r.Amount).

func (Builder[R]) Row

func (b Builder[R]) Row() Row[R]

Row provides the embedded schema during Define. Example: Fields{Row:b.Row(),ID:rows.IDOf(b,&r.ID)}.

type CheckedSchema

type CheckedSchema interface {
	// contains filtered or unexported methods
}

CheckedSchema is implemented by row declarations. Example: rows.Check(OrderRows).

type CommonTable

type CommonTable[R any] struct {
	// contains filtered or unexported fields
}

CommonTable is a reusable, complete, read-only record definition. Example: rows.AsRecord[tag](rows.CTE("active",records),"a").

func CTE

func CTE[R any](name string, source RecordSource[R]) CommonTable[R]

CTE names a complete model or projection; dependencies are emitted once per statement. Example: rows.CTE("active",rows.ModelRecord(Users.Query().Where(orm.ColumnEq(Users.Active, true)))).

func RecursiveAllCTE

func RecursiveAllCTE[R any](name string, anchor RecordSource[R], step func(RecursiveSelf[R]) RecordSource[R]) CommonTable[R]

RecursiveAllCTE retains duplicates and requires application data to terminate recursion. Execute with a cancellable context; an outer LIMIT is not a recursion bound. Example: rows.RecursiveAllCTE("paths",anchor,step).

func RecursiveCTE

func RecursiveCTE[R any](name string, anchor RecordSource[R], step func(RecursiveSelf[R]) RecordSource[R]) CommonTable[R]

RecursiveCTE uses UNION to remove duplicate complete records across iterations. The step runs once synchronously to build SQL and must reference self exactly once. Example: rows.RecursiveCTE("tree",anchor,func(self rows.RecursiveSelf[Node]) rows.RecordSource[Node] { return step(self) }).

func (CommonTable[R]) Materialized

func (c CommonTable[R]) Materialized() CommonTable[R]

Materialized requests explicit PostgreSQL materialization. Example: cte.Materialized().

func (CommonTable[R]) NotMaterialized

func (c CommonTable[R]) NotMaterialized() CommonTable[R]

NotMaterialized requests inlining; recursive definitions reject it. Example: cte.NotMaterialized().

type ConflictRow

type ConflictRow[M any] struct {
	// contains filtered or unexported fields
}

ConflictRow separates stored/proposed expressions from ordinary model queries. Example: rows.ConflictRow[User].

type ConflictRows

type ConflictRows[M any] struct {
	// contains filtered or unexported fields
}

ConflictRows exposes complete stored/proposed records without standalone SELECT. Example: rows.ConflictRowsOf(Users.Query()).

func ConflictRowsOf

func ConflictRowsOf[M any](q orm.Query[M]) ConflictRows[M]

ConflictRowsOf obtains declaration metadata; query filters do not become update conditions. Example: rows.ConflictRowsOf(Users.Query()).

func (ConflictRows[M]) Proposed

func (r ConflictRows[M]) Proposed() expr.Scope[ConflictRow[M], M]

Proposed identifies EXCLUDED, including defaults and trigger changes. Example: expr.At(records.Proposed(), orm.NumberExpr(Users.Age)).

func (ConflictRows[M]) Stored

func (r ConflictRows[M]) Stored() expr.Scope[ConflictRow[M], M]

Stored identifies the existing conflicting row. Example: expr.At(records.Stored(), orm.NumberExpr(Users.Age)).

type CorrelatedRecord

type CorrelatedRecord[O, I, R any] struct {
	// contains filtered or unexported fields
}

CorrelatedRecord keeps a complete record bound to its enclosing scope. Example: rows.SelectCorrelatedRecord(c,rows.InnerScope(c,scope)).

func DistinctCorrelatedRecord

func DistinctCorrelatedRecord[O, I, R any](q CorrelatedRecord[O, I, R]) CorrelatedRecord[O, I, R]

DistinctCorrelatedRecord removes duplicate inner results, replacing DISTINCT ON. Example: rows.DistinctCorrelatedRecord(selected).

func HavingCorrelatedRecord

func HavingCorrelatedRecord[O, I, R any](q CorrelatedRecord[O, I, R], predicates ...expr.HavingPredicate[Correlation[O, I]]) CorrelatedRecord[O, I, R]

HavingCorrelatedRecord appends group predicates inside the correlated SELECT. Example: rows.HavingCorrelatedRecord(summary, expr.GtValue(count, 0)).

func ProjectCorrelated

func ProjectCorrelated[O, I, R any](c CorrelatedSource[O, I], schema Schema[R], mappings ...Mapping[Correlation[O, I], R]) CorrelatedRecord[O, I, R]

ProjectCorrelated maps a complete declared record without granting execution. Example: rows.ProjectCorrelated(c,Totals,rows.MapSelected(Totals.Count,count)).

func SelectCorrelatedRecord

func SelectCorrelatedRecord[O, I, R any](c CorrelatedSource[O, I], scope expr.Scope[Correlation[O, I], R]) CorrelatedRecord[O, I, R]

SelectCorrelatedRecord selects a complete preserved inner model. Example: rows.SelectCorrelatedRecord(c,rows.InnerScope(c,rows.Scope(child))).

func (CorrelatedRecord[O, I, R]) Exists

func (r CorrelatedRecord[O, I, R]) Exists() expr.Predicate[O]

Exists tests the record within its required outer scope. Example: record.Exists().

func (CorrelatedRecord[O, I, R]) Limit

func (r CorrelatedRecord[O, I, R]) Limit(n int) CorrelatedRecord[O, I, R]

Limit retains the record's inner limit. Example: record.Limit(1).

func (CorrelatedRecord[O, I, R]) Offset

func (r CorrelatedRecord[O, I, R]) Offset(n int) CorrelatedRecord[O, I, R]

Offset retains the record's inner offset. Example: record.Offset(1).

func (CorrelatedRecord[O, I, R]) OrderBy

func (r CorrelatedRecord[O, I, R]) OrderBy(os ...expr.Order[Correlation[O, I]]) CorrelatedRecord[O, I, R]

OrderBy appends inner result ordering. Example: record.OrderBy(expr.Desc(childID)).

func (CorrelatedRecord[O, I, R]) Where

func (r CorrelatedRecord[O, I, R]) Where(ps ...expr.Predicate[Correlation[O, I]]) CorrelatedRecord[O, I, R]

Where appends lifted inner predicates. Example: record.Where(expr.Equal(childID,parentID)).

type CorrelatedScalar

type CorrelatedScalar[O, I, V any] struct {
	// contains filtered or unexported fields
}

CorrelatedScalar keeps one value bound to its enclosing scope. Example: rows.SelectCorrelatedScalar(c,expr.AsSelected(expr.Row(childID))).

func DistinctOnCorrelatedScalar

func DistinctOnCorrelatedScalar[O, I, V any](q CorrelatedScalar[O, I, V], keys ...expr.GroupKey[Correlation[O, I]]) CorrelatedScalar[O, I, V]

DistinctOnCorrelatedScalar selects one inner value per lifted row-key combination. Example: rows.DistinctOnCorrelatedScalar(selected, expr.Group(buyerID)).

func DistinctOnCorrelatedScalarValues

func DistinctOnCorrelatedScalarValues[O, I, V any](q CorrelatedScalar[O, I, V], keys ...expr.ProjectionKey[Correlation[O, I]]) CorrelatedScalar[O, I, V]

DistinctOnCorrelatedScalarValues accepts selected keys inside the correlated SELECT. Example: rows.DistinctOnCorrelatedScalarValues(selected, expr.Key(expr.AsSelected(count))).

func GroupByCorrelatedScalar

func GroupByCorrelatedScalar[O, I, V any](q CorrelatedScalar[O, I, V], keys ...expr.GroupKey[Correlation[O, I]]) CorrelatedScalar[O, I, V]

GroupByCorrelatedScalar appends lifted row keys inside the correlated SELECT. Example: rows.GroupByCorrelatedScalar(selected, expr.Group(bucket)).

func OrderCorrelatedScalar

func OrderCorrelatedScalar[O, I, V any](q CorrelatedScalar[O, I, V], orders ...expr.ProjectionOrder[Correlation[O, I]]) CorrelatedScalar[O, I, V]

OrderCorrelatedScalar appends row or selected ordering inside the correlated SELECT. Example: rows.OrderCorrelatedScalar(selected, expr.DescValue(count)).

func SelectCorrelatedScalar

func SelectCorrelatedScalar[O, I, V any](c CorrelatedSource[O, I], v expr.Selected[Correlation[O, I], V]) CorrelatedScalar[O, I, V]

SelectCorrelatedScalar selects one lifted value without an execution escape. Example: rows.SelectCorrelatedScalar(c,expr.AsSelected(expr.Count[rows.Correlation[User, Order]]())).

func (CorrelatedScalar[O, I, V]) Exists

func (s CorrelatedScalar[O, I, V]) Exists() expr.Predicate[O]

Exists tests the selected result in the enclosing scope. Example: selected.Limit(0).Exists().

func (CorrelatedScalar[O, I, V]) Limit

func (s CorrelatedScalar[O, I, V]) Limit(n int) CorrelatedScalar[O, I, V]

Limit retains an explicit inner limit. Example: selected.Limit(1).

func (CorrelatedScalar[O, I, V]) Offset

func (s CorrelatedScalar[O, I, V]) Offset(n int) CorrelatedScalar[O, I, V]

Offset retains an explicit inner offset. Example: selected.Offset(1).

func (CorrelatedScalar[O, I, V]) OrderBy

func (s CorrelatedScalar[O, I, V]) OrderBy(os ...expr.Order[Correlation[O, I]]) CorrelatedScalar[O, I, V]

OrderBy appends inner ordering. Example: selected.OrderBy(expr.Desc(childID)).

func (CorrelatedScalar[O, I, V]) Where

func (s CorrelatedScalar[O, I, V]) Where(ps ...expr.Predicate[Correlation[O, I]]) CorrelatedScalar[O, I, V]

Where filters the inner SELECT with lifted predicates. Example: selected.Where(expr.Equal(childID,parentID)).

type CorrelatedSource

type CorrelatedSource[O, I any] struct {
	// contains filtered or unexported fields
}

CorrelatedSource retains its enclosing scope and cannot execute independently. Example: rows.Correlate(rows.From(users),rows.From(orders)).

func Correlate

func Correlate[O, I any](outer ScopeSource[O], inner SelectionSource[I]) CorrelatedSource[O, I]

Correlate makes only the supplied enclosing scopes visible inside inner. Example: rows.Correlate(parent,child).

func (CorrelatedSource[O, I]) Exists

func (c CorrelatedSource[O, I]) Exists() expr.Predicate[O]

Exists returns a predicate in the enclosing scope. Example: expr.Where(users,c.Exists()).

func (CorrelatedSource[O, I]) Limit

func (c CorrelatedSource[O, I]) Limit(n int) CorrelatedSource[O, I]

Limit retains an inner result limit. Example: c.Limit(1).

func (CorrelatedSource[O, I]) Offset

func (c CorrelatedSource[O, I]) Offset(n int) CorrelatedSource[O, I]

Offset retains an inner result offset. Example: c.Offset(1).

func (CorrelatedSource[O, I]) OrderBy

func (c CorrelatedSource[O, I]) OrderBy(os ...expr.Order[Correlation[O, I]]) CorrelatedSource[O, I]

OrderBy appends scoped ordering. Example: c.OrderBy(expr.Desc(childID)).

func (CorrelatedSource[O, I]) Where

func (c CorrelatedSource[O, I]) Where(ps ...expr.Predicate[Correlation[O, I]]) CorrelatedSource[O, I]

Where appends predicates in the lifted correlation scope. Example: c.Where(expr.Equal(childID,parentID)).

type Correlation

type Correlation[O, I any] struct {
	// contains filtered or unexported fields
}

Correlation identifies an explicit enclosing/inner scope pair. Example: Correlation[User,Order].

type Cross

type Cross[L, R any] struct {
	// contains filtered or unexported fields
}

Cross identifies a cross join's distinct result scope. Example: rows.Cross[L,R].

type CrossJoined

type CrossJoined[L, R any] struct {
	// contains filtered or unexported fields
}

CrossJoined retains typed sides and non-generic join state. Example: rows.CrossJoin(a,b).

func CrossJoin

func CrossJoin[L, R any](left Source[L], right JoinTable[R]) CrossJoined[L, R]

CrossJoin combines aliased inputs with cross join semantics. Example: rows.CrossJoin(a,b).

func CrossJoinLateral

func CrossJoinLateral[L, A, R any](left Source[L], right LateralSource[A, L, R]) CrossJoined[L, Alias[A, R]]

CrossJoinLateral evaluates right for each preceding left row. Example: rows.CrossJoinLateral(parent,latest).

type CursorQuery

type CursorQuery[R any] struct {
	// contains filtered or unexported fields
}

CursorQuery pages complete results using an explicit unique output identity. Example: rows.CursorFor(rows.ModelRecord(Users.Query())).

func CursorFor

func CursorFor[R any](source RecordSource[R]) CursorQuery[R]

CursorFor retains filters and windows behind a completed-result boundary. Example: rows.CursorFor(rows.RecordOf(report)).UniqueBy(expr.Group(id)).

func (CursorQuery[R]) OrderBy

func (q CursorQuery[R]) OrderBy(os ...expr.ProjectionOrder[CursorScope[R]]) CursorQuery[R]

OrderBy orders plain output fields. Example: c.OrderBy(expr.Asc(id)).

func (CursorQuery[R]) Paginate

func (q CursorQuery[R]) Paginate(ctx context.Context, ex database.Executor, r orm.CursorRequest[R]) (orm.CursorPage[R], error)

Paginate reads one lookahead row; tokens are positions, not authorization. Example: c.Paginate(ctx,db,orm.CursorRequest[R]{Size:20}).

func (CursorQuery[R]) Scope

func (q CursorQuery[R]) Scope() expr.Scope[CursorScope[R], R]

Scope exposes completed output fields. Example: expr.At(c.Scope(), orm.KeyExpr(Users.ID)).

func (CursorQuery[R]) UniqueBy

func (q CursorQuery[R]) UniqueBy(keys ...expr.GroupKey[CursorScope[R]]) CursorQuery[R]

UniqueBy asserts result uniqueness and appends missing identity orders. Example: c.UniqueBy(expr.Group(id)).

func (CursorQuery[R]) Where

func (q CursorQuery[R]) Where(ps ...expr.Predicate[CursorScope[R]]) CursorQuery[R]

Where filters completed rows. Example: c.Where(expr.Ne(id, zero)).

type CursorScope

type CursorScope[R any] struct {
	// contains filtered or unexported fields
}

CursorScope identifies completed output independently of the input scope. Example: expr.At(cursor.Scope(), orm.KeyExpr(Users.ID)).

type Field

type Field[R, V any] struct {
	// contains filtered or unexported fields
}

Field preserves the row and value types of one result field. Example: rows.Map(OrderRows.Amount,amount).

func BoolOf

func BoolOf[R any, V ~bool](b Builder[R], ptr *V) Field[R, V]

BoolOf binds a Boolean row field, including defined Boolean types. Example: rows.BoolOf(b, &r.Enabled).

func BytesOf

func BytesOf[R any, V ~[]byte](b Builder[R], ptr *V) Field[R, V]

BytesOf binds an owned byte buffer. Example: rows.BytesOf(b,&r.Payload).

func EnumOf

func EnumOf[R any, E interface {
	enum.Scalar
	EnumDescriptor() enum.Descriptor[E]
}](b Builder[R], ptr *E) Field[R, E]

EnumOf validates and uses the generated descriptor. Example: rows.EnumOf(b,&r.Status).

func FieldOf

func FieldOf[R, V any](b Builder[R], ptr *V, option orm.ColumnOption[V]) Field[R, V]

FieldOf binds a custom row value with an explicit codec. Example: rows.FieldOf(b,&r.Code,orm.Codec(custom)).

func IDOf

func IDOf[R, M any](b Builder[R], ptr *model.ID[M]) Field[R, model.ID[M]]

IDOf binds a model-owned identifier. Example: rows.IDOf(b,&r.ID).

func NullableBytesOf

func NullableBytesOf[R any, V ~[]byte](b Builder[R], ptr *value.Nullable[V]) Field[R, value.Nullable[V]]

NullableBytesOf binds nullable owned buffers. Example: rows.NullableBytesOf(b,&r.Payload).

func NullableEnumOf

func NullableEnumOf[R any, E interface {
	enum.Scalar
	EnumDescriptor() enum.Descriptor[E]
}](b Builder[R], ptr *value.Nullable[E]) Field[R, value.Nullable[E]]

NullableEnumOf binds nullable enums with their generated descriptor. Example: rows.NullableEnumOf(b,&r.Status).

func NullableFieldOf

func NullableFieldOf[R, V any](b Builder[R], ptr *value.Nullable[V], option orm.ColumnOption[V]) Field[R, value.Nullable[V]]

NullableFieldOf binds a nullable custom value. Example: rows.NullableFieldOf(b,&r.Code,orm.Codec(custom)).

func NullableIDOf

func NullableIDOf[R, M any](b Builder[R], ptr *value.Nullable[model.ID[M]]) Field[R, value.Nullable[model.ID[M]]]

NullableIDOf binds a nullable model identifier. Example: rows.NullableIDOf(b,&r.OwnerID).

func NullableNumberOf

func NullableNumberOf[R any, V orm.NumberValue](b Builder[R], ptr *value.Nullable[V]) Field[R, value.Nullable[V]]

NullableNumberOf chooses a nullable numeric codec. Example: rows.NullableNumberOf(b,&r.Balance).

func NullableTextOf

func NullableTextOf[R any, V ~string](b Builder[R], ptr *value.Nullable[V]) Field[R, value.Nullable[V]]

NullableTextOf binds nullable text. Example: rows.NullableTextOf(b,&r.Nickname).

func NullableTimeOf

func NullableTimeOf[R any, V orm.TimeValue](b Builder[R], ptr *value.Nullable[V]) Field[R, value.Nullable[V]]

NullableTimeOf chooses a nullable temporal codec. Example: rows.NullableTimeOf(b,&r.DeletedAt).

func NumberOf

func NumberOf[R any, V orm.NumberValue](b Builder[R], ptr *V) Field[R, V]

NumberOf chooses the numeric codec at startup. Example: rows.NumberOf(b,&r.Amount).

func TextOf

func TextOf[R any, V ~string](b Builder[R], ptr *V) Field[R, V]

TextOf binds a string or defined string type. Example: rows.TextOf(b,&r.Label).

func TimeOf

func TimeOf[R any, V orm.TimeValue](b Builder[R], ptr *V) Field[R, V]

TimeOf chooses the temporal codec at startup. Example: rows.TimeOf(b,&r.CreatedAt).

type Full

type Full[L, R any] struct {
	// contains filtered or unexported fields
}

Full identifies a full join's distinct result scope. Example: rows.Full[L,R].

type FullJoined

type FullJoined[L, R any] struct {
	// contains filtered or unexported fields
}

FullJoined retains typed sides and non-generic join state. Example: rows.FullJoin(a,b,on).

func FullJoin

func FullJoin[L, R any](left Source[L], right JoinTable[R], on JoinOn[L, R]) FullJoined[L, R]

FullJoin combines aliased inputs with full join semantics. Example: rows.FullJoin(a,b,on).

type Inner

type Inner[L, R any] struct {
	// contains filtered or unexported fields
}

Inner preserves the scopes of both joined inputs. Example: Inner[Alias[left,Member],Alias[right,Order]].

type InnerJoined

type InnerJoined[L, R any] struct {
	// contains filtered or unexported fields
}

InnerJoined retains both sides for type-safe re-scoping. Example: rows.InnerJoin(members,orders,on).

func InnerJoin

func InnerJoin[L, R any](left Source[L], right JoinTable[R], on JoinOn[L, R]) InnerJoined[L, R]

InnerJoin joins two distinct typed aliases. Example: rows.InnerJoin(members,orders,rows.On(mID,oMemberID)).

func InnerJoinLateral

func InnerJoinLateral[L, A, R any](left Source[L], right LateralSource[A, L, R], on ...JoinOn[L, Alias[A, R]]) InnerJoined[L, Alias[A, R]]

InnerJoinLateral combines optional typed ON conditions; no conditions means ON TRUE. Example: rows.InnerJoinLateral(parent,latest).

type Input

type Input[S any] struct {
	// contains filtered or unexported fields
}

Input retains a SELECT's scope without adding methods to model or row queries. Example: rows.From(Users.Query()).

func From

func From[M any](q orm.Query[M]) Input[M]

From adapts an ordinary model query for scoped SELECT composition. Example: rows.From(Users.Query().Limit(1)).

func FromRows

func FromRows[S, R any](q Query[S, R]) Input[S]

FromRows retains projected filters, windows and deferred schema checks. Example: rows.FromRows(report.Where(condition)).

type JoinOn

type JoinOn[L, R any] struct {
	// contains filtered or unexported fields
}

JoinOn retains the two operand scopes. Example: rows.On(memberID,orderMemberID).

func On

func On[L, R any, K comparable, LP, RP any](left expr.Expression[L, K, LP], right expr.Expression[R, K, RP]) JoinOn[L, R]

On joins expressions with the same value type. Example: rows.On(memberID,orderMemberID).

func OnAnd

func OnAnd[L, R any](conditions ...JoinOn[L, R]) JoinOn[L, R]

OnAnd combines conditions with the same left/right scopes. Example: rows.OnAnd(key,age).

func OnDistinctFrom

func OnDistinctFrom[L, R any, V any](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnDistinctFrom compares same-typed row values across distinct join sides. Example: rows.OnDistinctFrom(left,right).

func OnEqual

func OnEqual[L, R any, V any](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnEqual compares same-typed row values across distinct join sides. Example: rows.OnEqual(left,right).

func OnGreater

func OnGreater[L, R any, V expr.OrderedScalar](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnGreater compares same-typed row values across distinct join sides. Example: rows.OnGreater(left,right).

func OnGreaterNullable

func OnGreaterNullable[L, R any, V expr.OrderedScalar](left expr.RowValue[L, value.Nullable[V]], right expr.RowValue[R, value.Nullable[V]]) JoinOn[L, R]

OnGreaterNullable compares same-typed row values across distinct join sides. Example: rows.OnGreaterNullable(left,right).

func OnGreaterOrEqual

func OnGreaterOrEqual[L, R any, V expr.OrderedScalar](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnGreaterOrEqual compares same-typed row values across distinct join sides. Example: rows.OnGreaterOrEqual(left,right).

func OnGreaterOrEqualNullable

func OnGreaterOrEqualNullable[L, R any, V expr.OrderedScalar](left expr.RowValue[L, value.Nullable[V]], right expr.RowValue[R, value.Nullable[V]]) JoinOn[L, R]

OnGreaterOrEqualNullable compares same-typed row values across distinct join sides. Example: rows.OnGreaterOrEqualNullable(left,right).

func OnLess

func OnLess[L, R any, V expr.OrderedScalar](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnLess compares same-typed row values across distinct join sides. Example: rows.OnLess(left,right).

func OnLessNullable

func OnLessNullable[L, R any, V expr.OrderedScalar](left expr.RowValue[L, value.Nullable[V]], right expr.RowValue[R, value.Nullable[V]]) JoinOn[L, R]

OnLessNullable compares same-typed row values across distinct join sides. Example: rows.OnLessNullable(left,right).

func OnLessOrEqual

func OnLessOrEqual[L, R any, V expr.OrderedScalar](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnLessOrEqual compares same-typed row values across distinct join sides. Example: rows.OnLessOrEqual(left,right).

func OnLessOrEqualNullable

func OnLessOrEqualNullable[L, R any, V expr.OrderedScalar](left expr.RowValue[L, value.Nullable[V]], right expr.RowValue[R, value.Nullable[V]]) JoinOn[L, R]

OnLessOrEqualNullable compares same-typed row values across distinct join sides. Example: rows.OnLessOrEqualNullable(left,right).

func OnLike

func OnLike[L, R any, V ~string](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnLike compares same-typed row values across distinct join sides. Example: rows.OnLike(left,right).

func OnLikeNullable

func OnLikeNullable[L, R any, V ~string](left expr.RowValue[L, value.Nullable[V]], right expr.RowValue[R, value.Nullable[V]]) JoinOn[L, R]

OnLikeNullable compares same-typed row values across distinct join sides. Example: rows.OnLikeNullable(left,right).

func OnNotDistinctFrom

func OnNotDistinctFrom[L, R any, V any](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnNotDistinctFrom compares same-typed row values across distinct join sides. Example: rows.OnNotDistinctFrom(left,right).

func OnNotEqual

func OnNotEqual[L, R any, V any](left expr.RowValue[L, V], right expr.RowValue[R, V]) JoinOn[L, R]

OnNotEqual compares same-typed row values across distinct join sides. Example: rows.OnNotEqual(left,right).

func OnOr

func OnOr[L, R any](conditions ...JoinOn[L, R]) JoinOn[L, R]

OnOr combines alternatives without changing side ownership. Example: rows.OnOr(primary,fallback).

func (JoinOn[L, R]) Not

func (on JoinOn[L, R]) Not() JoinOn[L, R]

Not negates ON with SQL NULL semantics. Example: condition.Not().

func (JoinOn[L, R]) WhereLeft

func (on JoinOn[L, R]) WhereLeft(predicates ...expr.Predicate[L]) JoinOn[L, R]

WhereLeft adds predicates owned by the left input, preserving outer rows. Example: on.WhereLeft(expr.Eq(left, 1)).

func (JoinOn[L, R]) WhereRight

func (on JoinOn[L, R]) WhereRight(predicates ...expr.Predicate[R]) JoinOn[L, R]

WhereRight adds predicates owned by the right input. Example: on.WhereRight(expr.Eq(right, 1)).

type JoinTable

type JoinTable[S any] interface {
	Source[S]
	// contains filtered or unexported methods
}

JoinTable accepts only a single aliased table on the right side of a join.

type LateralSource

type LateralSource[A, O, R any] struct {
	// contains filtered or unexported fields
}

LateralSource retains its required preceding scope without ordinary source methods. Example: rows.AsLateral[latest](record,"latest").

func AsLateral

func AsLateral[A, O, I, R any](record CorrelatedRecord[O, I, R], alias string) LateralSource[A, O, R]

AsLateral always creates a derived SELECT for a correlated record. Example: rows.AsLateral[latest](record.Limit(1),"latest").

type Left

type Left[L, R any] struct {
	// contains filtered or unexported fields
}

Left identifies a left join's distinct result scope. Example: rows.Left[L,R].

type LeftJoined

type LeftJoined[L, R any] struct {
	// contains filtered or unexported fields
}

LeftJoined retains typed sides and non-generic join state. Example: rows.LeftJoin(a,b,on).

func LeftJoin

func LeftJoin[L, R any](left Source[L], right JoinTable[R], on JoinOn[L, R]) LeftJoined[L, R]

LeftJoin combines aliased inputs with left join semantics. Example: rows.LeftJoin(a,b,on).

func LeftJoinLateral

func LeftJoinLateral[L, A, R any](left Source[L], right LateralSource[A, L, R], on ...JoinOn[L, Alias[A, R]]) LeftJoined[L, Alias[A, R]]

LeftJoinLateral preserves unmatched parents and widens the right scope. Example: rows.LeftJoinLateral(parent,latest).

type LockTarget

type LockTarget[S any] struct {
	// contains filtered or unexported fields
}

LockTarget identifies one preserved input; nullable scopes are excluded. Example: rows.Target(rows.Scope(users)).

func Target

func Target[S, R any](scope expr.Scope[S, R]) LockTarget[S]

Target retains scope and declaration ownership for a lock target. Example: locked.Of(rows.Target(rows.Scope(users))).

type LockedResult

type LockedResult[S, R any] struct {
	// contains filtered or unexported fields
}

LockedResult requires Tx and offers no count, pagination or ordinary source conversion. Example: rows.ForUpdate(rows.Read(report)).All(ctx,tx).

func ForKeyShare

func ForKeyShare[S, R any](source ReadSource[S, R]) LockedResult[S, R]

ForKeyShare locks eligible contributing rows; narrow outer joins with Of. Example: rows.ForKeyShare(rows.Read(report)).All(ctx,tx).

func ForNoKeyUpdate

func ForNoKeyUpdate[S, R any](source ReadSource[S, R]) LockedResult[S, R]

ForNoKeyUpdate locks eligible contributing rows; narrow outer joins with Of. Example: rows.ForNoKeyUpdate(rows.Read(report)).All(ctx,tx).

func ForShare

func ForShare[S, R any](source ReadSource[S, R]) LockedResult[S, R]

ForShare locks eligible contributing rows; narrow outer joins with Of. Example: rows.ForShare(rows.Read(report)).All(ctx,tx).

func ForUpdate

func ForUpdate[S, R any](source ReadSource[S, R]) LockedResult[S, R]

ForUpdate locks eligible contributing rows; narrow outer joins with Of. Example: rows.ForUpdate(rows.Read(report)).All(ctx,tx).

func LockRows

func LockRows[S, R any](source ReadSource[S, R], clauses ...RowLock[S]) LockedResult[S, R]

LockRows applies independent clauses using the existing lock compiler. Example: rows.LockRows(rows.Read(report),rows.UpdateLock(rows.Target(scope))).

func (LockedResult[S, R]) All

func (q LockedResult[S, R]) All(ctx context.Context, tx *database.Tx) ([]R, error)

All requires a transaction and discards partial results. Example: locked.All(ctx,tx).

func (LockedResult[S, R]) First

func (q LockedResult[S, R]) First(ctx context.Context, tx *database.Tx) (value.Optional[R], error)

First preserves an omitted result when no row matches. Example: locked.First(ctx,tx).

func (LockedResult[S, R]) Limit

func (q LockedResult[S, R]) Limit(n int) LockedResult[S, R]

Limit bounds selected rows. Example: locked.Limit(10).

func (LockedResult[S, R]) NoWait

func (q LockedResult[S, R]) NoWait() LockedResult[S, R]

NoWait sets every clause's wait policy. Example: locked.NoWait().

func (LockedResult[S, R]) Of

func (q LockedResult[S, R]) Of(targets ...LockTarget[S]) LockedResult[S, R]

Of replaces a single clause's targets with preserved scopes. Example: locked.Of(rows.Target(scope)).

func (LockedResult[S, R]) Offset

func (q LockedResult[S, R]) Offset(n int) LockedResult[S, R]

Offset skips selected rows. Example: locked.Offset(10).

func (LockedResult[S, R]) OrderBy

func (q LockedResult[S, R]) OrderBy(os ...expr.ProjectionOrder[S]) LockedResult[S, R]

OrderBy orders contributing rows. Example: locked.OrderBy(expr.Asc(id)).

func (LockedResult[S, R]) RequireFirst

func (q LockedResult[S, R]) RequireFirst(ctx context.Context, tx *database.Tx) (R, error)

RequireFirst reports database.NotFound when no row matches. Example: locked.RequireFirst(ctx,tx).

func (LockedResult[S, R]) SkipLocked

func (q LockedResult[S, R]) SkipLocked() LockedResult[S, R]

SkipLocked sets every clause's wait policy. Example: locked.SkipLocked().

func (LockedResult[S, R]) Wait

func (q LockedResult[S, R]) Wait() LockedResult[S, R]

Wait sets every clause's wait policy. Example: locked.Wait().

func (LockedResult[S, R]) Where

func (q LockedResult[S, R]) Where(ps ...expr.Predicate[S]) LockedResult[S, R]

Where filters contributing rows. Example: locked.Where(expr.Ne(id, zero)).

type Mapping

type Mapping[S, R any] struct {
	// contains filtered or unexported fields
}

Mapping binds a row field to a same-typed expression in S. Example: rows.Map(OrderRows.Label,label).

func Map

func Map[S, R, V, P any](field Field[R, P], expression expr.Expression[S, V, P]) Mapping[S, R]

Map requires an exact result-field value type. Example: rows.Map(OrderRows.Amount,amount).

func MapSelected

func MapSelected[S, R, V any](field Field[R, V], expression expr.Selected[S, V]) Mapping[S, R]

MapSelected binds a row field to an exactly typed selected value, including aggregates. Example: rows.MapSelected(Totals.Count,expr.AsSelected(expr.Count[Scope]())).

type Query

type Query[S, R any] struct {
	// contains filtered or unexported fields
}

Query retains input scope S and result R without heavy engine types. Example: rows.Read(projection).All(ctx,db).

func Distinct

func Distinct[S, R any](q Query[S, R]) Query[S, R]

Distinct removes duplicate results and replaces earlier DISTINCT ON. Example: rows.Distinct(rows.FromModel(Users.Query())).

func DistinctOn

func DistinctOn[S, R any](q Query[S, R], keys ...expr.GroupKey[S]) Query[S, R]

DistinctOn selects one result per row-key combination; order by keys first. Example: rows.DistinctOn(q,expr.Group(buyer)).

func DistinctOnValues

func DistinctOnValues[S, R any](q Query[S, R], keys ...expr.ProjectionKey[S]) Query[S, R]

DistinctOnValues accepts selected keys while preserving grouping validation. Example: rows.DistinctOnValues(q,expr.Key(expr.AsSelected(count))).

func FromModel

func FromModel[M any](q orm.Query[M]) Query[M, M]

FromModel adapts a model query to a complete read-only model result/source. Scopes remain applied; eager-loading requests require explicit collection loading. Example: rows.Read(rows.Distinct(rows.FromModel(Users.Query()))).All(ctx,db).

func GroupBy

func GroupBy[S, R any](q Query[S, R], keys ...expr.GroupKey[S]) Query[S, R]

GroupBy appends row-phase grouping keys. Example: rows.GroupBy(q,expr.Group(buyer)).

func Having

func Having[S, R any](q Query[S, R], predicates ...expr.HavingPredicate[S]) Query[S, R]

Having appends group conditions. Example: rows.Having(q,expr.GtValue(count, 0)).

func Limit

func Limit[S, R any](q Query[S, R], n int) Query[S, R]

Limit retains an ordinary projection's window without adding Query methods. Example: rows.Limit(report,10).

func Offset

func Offset[S, R any](q Query[S, R], n int) Query[S, R]

Offset retains an ordinary projection's offset without adding Query methods. Example: rows.Offset(report,10).

func OrderBy

func OrderBy[S, R any](q Query[S, R], orders ...expr.ProjectionOrder[S]) Query[S, R]

OrderBy accepts row and selected ordering through this read-only boundary. Example: rows.OrderBy(q,expr.DescValue(count),expr.Asc(buyer)).

func ReorderUnwindowed

func ReorderUnwindowed[S, R any](q Query[S, R], orders ...expr.ProjectionOrder[S]) Query[S, R]

ReorderUnwindowed replaces report ordering, rejecting outer windows and DISTINCT ON. Example: rows.ReorderUnwindowed(q,expr.Asc(name),expr.Asc(id)).

func Select

func Select[S, R any](source SelectionSource[S], schema Schema[R], mappings ...Mapping[S, R]) Query[S, R]

Select maps every declared row field exactly once. Example: rows.Select(joined,OrderRows,rows.Map(OrderRows.ID,id),...).

func SelectValue

func SelectValue[M, V, P any](source orm.Query[M], column orm.ExpressionColumn[M, V, P]) Query[M, P]

SelectValue selects just a column's value type. Example: rows.SelectValue(Orders.Query(), orm.NumberExpr(Orders.TotalCents)).

func (Query[S, R]) Where

func (q Query[S, R]) Where(predicates ...expr.Predicate[S]) Query[S, R]

Where appends scoped predicates. Example: report.Where(expr.Eq(memberTenant, tenant)).

type ReadSource

type ReadSource[S, R any] interface {
	// contains filtered or unexported methods
}

ReadSource carries scope, complete decoding and executor kind together for locking. Example: rows.ForUpdate(rows.Read(report)).

type Record

type Record[R any] struct {
	// contains filtered or unexported fields
}

Record is a complete ordinary result adapter without execution or mutation methods. Example: rows.ModelRecord(Orders.Query()).

func ModelRecord

func ModelRecord[M any](q orm.Query[M]) Record[M]

ModelRecord adapts a model read without eager loading or write capabilities. Example: rows.ModelRecord(Users.Query().Limit(10)).

func RecordOf

func RecordOf[S, R any](q Query[S, R]) Record[R]

RecordOf retains the declaration of a complete projected or FromModel result. Scalar-only and uninitialized queries fail validation before SQL. Example: rows.RecordOf(rows.Select(source,Summary,mappings...)).

type RecordRead

type RecordRead[S, R any] struct {
	// contains filtered or unexported fields
}

RecordRead retains the input scope and complete record decoder without model writes. Example: rows.ReadRecord(rows.SelectRecord(alias,rows.Scope(alias))).All(ctx,db).

func DistinctOnRecord

func DistinctOnRecord[S, R any](q RecordRead[S, R], keys ...expr.GroupKey[S]) RecordRead[S, R]

DistinctOnRecord selects a complete read-only record per input-key combination. Ordering stays in the input scope, including columns not in the selected record. Example: rows.DistinctOnRecord(rows.SelectRecord(joined,left),expr.Group(buyerID)).OrderBy(expr.Asc(buyerID),expr.Desc(orderID)).

func DistinctRecord

func DistinctRecord[S, R any](q RecordRead[S, R]) RecordRead[S, R]

DistinctRecord removes duplicate complete records without adding model writes. Example: rows.DistinctRecord(rows.SelectRecord(joined, scope)).

func SelectRecord

func SelectRecord[S, R any](source SelectionSource[S], scope expr.Scope[S, R]) RecordRead[S, R]

SelectRecord selects a complete preserved source through its original decoder. Nullable sides require an explicit declared projection instead. Example: rows.SelectRecord(joined,rows.LeftScope(joined,rows.Scope(parent))).

func WithValue

func WithValue[M, V any](q orm.Query[M], computed expr.RowValue[M, V]) RecordRead[M, Annotated[M, V]]

WithValue selects a complete model and a computed row value in one statement. Model retrieval callbacks and eager relations retain their ordinary ownership. Example: rows.ReadRecord(rows.WithValue(Users.Query(),expr.RelatedValue(UserRelations.Orders,expr.Count[Order]()))).All(ctx,db).

func (RecordRead[S, R]) Limit

func (r RecordRead[S, R]) Limit(n int) RecordRead[S, R]

Limit retains the result window. Example: result.Limit(10).

func (RecordRead[S, R]) Offset

func (r RecordRead[S, R]) Offset(n int) RecordRead[S, R]

Offset retains the result offset. Example: result.Offset(10).

func (RecordRead[S, R]) OrderBy

func (r RecordRead[S, R]) OrderBy(os ...expr.ProjectionOrder[S]) RecordRead[S, R]

OrderBy retains row or selected ordering. Example: result.OrderBy(expr.Asc(id)).

func (RecordRead[S, R]) Where

func (r RecordRead[S, R]) Where(ps ...expr.Predicate[S]) RecordRead[S, R]

Where retains predicates in the input scope. Example: result.Where(expr.Gt(id, 0)).

type RecordSource

type RecordSource[R any] interface {
	// contains filtered or unexported methods
}

RecordSource carries a complete declared result, separately from its input scope. Example: rows.AsRecord[tag](rows.RecordOf(report),"report").

type RecursiveSelf

type RecursiveSelf[R any] struct {
	// contains filtered or unexported fields
}

RecursiveSelf exposes the working record only through a typed alias. Captured references fail compilation outside their owning recursive step. Example: rows.AsRecord[parent](self,"parent").

type Result

type Result[S, R any] struct {
	// contains filtered or unexported fields
}

Result exposes ordinary read terminals without adding Query methods. Example: rows.Read(report).Paginate(ctx,db,orm.Page(1,20)).

func Read

func Read[S, R any](q Query[S, R]) Result[S, R]

Read adapts complete projections and single-value queries for ordinary terminals. Example: rows.Read(rows.SelectValue(Users.Query(), orm.TextExpr(Users.Name))).First(ctx,db).

func ReadRecord

func ReadRecord[S, R any](q RecordRead[S, R]) Result[S, R]

ReadRecord adapts complete selected records for ordinary terminals. Example: rows.ReadRecord(selected).First(ctx,db).

func ReadScalar

func ReadScalar[S, V any](q Scalar[S, V]) Result[S, V]

ReadScalar adapts a selected scalar with its exact codec. Example: rows.ReadScalar(selected).All(ctx,db).

func ReadSet

func ReadSet[R any](q SetQuery[R]) Result[Set[R], R]

ReadSet adapts the completed scope of a record set. Example: rows.ReadSet(combined).Count(ctx,db).

func ReadValues

func ReadValues[V any](q ValueSetQuery[V]) Result[Set[V], V]

ReadValues adapts the completed scope of a scalar set. Example: rows.ReadValues(combined).SimplePaginate(ctx,db,orm.Page(1,20)).

func (Result[S, R]) All

func (q Result[S, R]) All(ctx context.Context, ex database.Executor) ([]R, error)

All collects complete results or discards the entire batch. Example: selected.All(ctx,executor).

func (Result[S, R]) Count

func (q Result[S, R]) Count(ctx context.Context, ex database.Executor) (int64, error)

Count counts the selected window, preserving nested locks. Example: selected.Count(ctx,executor).

func (Result[S, R]) Exists

func (q Result[S, R]) Exists(ctx context.Context, ex database.Executor) (bool, error)

Exists tests the selected window. Example: selected.Exists(ctx,executor).

func (Result[S, R]) First

func (q Result[S, R]) First(ctx context.Context, ex database.Executor) (value.Optional[R], error)

First returns an omitted optional for an empty result. Example: selected.First(ctx,executor).

func (Result[S, R]) Limit

func (q Result[S, R]) Limit(n int) Result[S, R]

Limit bounds selected rows. Example: selected.Limit(10).

func (Result[S, R]) Offset

func (q Result[S, R]) Offset(n int) Result[S, R]

Offset skips selected rows. Example: selected.Offset(10).

func (Result[S, R]) OrderBy

func (q Result[S, R]) OrderBy(os ...expr.ProjectionOrder[S]) Result[S, R]

OrderBy retains explicit result ordering. Example: selected.OrderBy(expr.Asc(id)).

func (Result[S, R]) Paginate

func (q Result[S, R]) Paginate(ctx context.Context, ex database.Executor, request orm.PageRequest) (orm.PageResult[R], error)

Paginate requires explicit ordering and no outer window; nested windows remain. Example: rows.Read(report).Paginate(ctx,db,orm.Page(1,20)).

func (Result[S, R]) RequireFirst

func (q Result[S, R]) RequireFirst(ctx context.Context, ex database.Executor) (R, error)

RequireFirst reports database.NotFound for an empty result. Example: selected.RequireFirst(ctx,executor).

func (Result[S, R]) SimplePaginate

func (q Result[S, R]) SimplePaginate(ctx context.Context, ex database.Executor, request orm.PageRequest) (orm.SimplePage[R], error)

SimplePaginate reads one lookahead row without a total. Example: rows.Read(report).SimplePaginate(ctx,db,orm.Page(1,20)).

func (Result[S, R]) Where

func (q Result[S, R]) Where(ps ...expr.Predicate[S]) Result[S, R]

Where filters the retained input scope. Example: selected.Where(expr.Ne(id, zero)).

type Right[L, R any] struct {
	// contains filtered or unexported fields
}

Right identifies a right join's distinct result scope. Example: rows.Right[L,R].

type RightJoined

type RightJoined[L, R any] struct {
	// contains filtered or unexported fields
}

RightJoined retains typed sides and non-generic join state. Example: rows.RightJoin(a,b,on).

func RightJoin

func RightJoin[L, R any](left Source[L], right JoinTable[R], on JoinOn[L, R]) RightJoined[L, R]

RightJoin combines aliased inputs with right join semantics. Example: rows.RightJoin(a,b,on).

type Row

type Row[R any] struct {
	// contains filtered or unexported fields
}

Row is embedded in a row-field schema. Example: type Fields struct { rows.Row[OrderRow]; ID rows.Field[OrderRow,model.ID[Order]] }.

type RowLock

type RowLock[S any] struct {
	// contains filtered or unexported fields
}

RowLock declares one lock strength and wait policy for preserved inputs. Example: rows.UpdateLock(rows.Target(scope)).SkipLocked().

func KeyShareLock

func KeyShareLock[S any](targets ...LockTarget[S]) RowLock[S]

KeyShareLock declares a lock on explicit preserved targets. Example: rows.KeyShareLock(rows.Target(scope)).

func NoKeyUpdateLock

func NoKeyUpdateLock[S any](targets ...LockTarget[S]) RowLock[S]

NoKeyUpdateLock declares a lock on explicit preserved targets. Example: rows.NoKeyUpdateLock(rows.Target(scope)).

func ShareLock

func ShareLock[S any](targets ...LockTarget[S]) RowLock[S]

ShareLock declares a lock on explicit preserved targets. Example: rows.ShareLock(rows.Target(scope)).

func UpdateLock

func UpdateLock[S any](targets ...LockTarget[S]) RowLock[S]

UpdateLock declares a lock on explicit preserved targets. Example: rows.UpdateLock(rows.Target(scope)).

func (RowLock[S]) NoWait

func (q RowLock[S]) NoWait() RowLock[S]

NoWait sets this clause's wait policy. Example: clause.NoWait().

func (RowLock[S]) SkipLocked

func (q RowLock[S]) SkipLocked() RowLock[S]

SkipLocked sets this clause's wait policy. Example: clause.SkipLocked().

func (RowLock[S]) Wait

func (q RowLock[S]) Wait() RowLock[S]

Wait sets this clause's wait policy. Example: clause.Wait().

type Scalar

type Scalar[S, V any] struct {
	// contains filtered or unexported fields
}

Scalar retains exactly one selected value without standalone execution. Example: rows.SelectScalar(rows.From(q),expr.AsSelected(expr.Row(age))).

func DistinctOnScalar

func DistinctOnScalar[S, V any](q Scalar[S, V], keys ...expr.GroupKey[S]) Scalar[S, V]

DistinctOnScalar selects one scalar per row-key combination; order by keys first. Example: rows.DistinctOnScalar(selected, expr.Group(buyer)).

func DistinctOnScalarValues

func DistinctOnScalarValues[S, V any](q Scalar[S, V], keys ...expr.ProjectionKey[S]) Scalar[S, V]

DistinctOnScalarValues accepts selected keys and retains group/window validation. Example: rows.DistinctOnScalarValues(selected, expr.Key(expr.AsSelected(count))).

func DistinctScalar

func DistinctScalar[S, V any](q Scalar[S, V]) Scalar[S, V]

DistinctScalar removes duplicate scalar results, replacing DISTINCT ON. Example: rows.DistinctScalar(selected).

func GroupByScalar

func GroupByScalar[S, V any](q Scalar[S, V], keys ...expr.GroupKey[S]) Scalar[S, V]

GroupByScalar appends row keys inside the scalar SELECT. Example: rows.GroupByScalar(selected, expr.Group(buyer)).

func HavingScalar

func HavingScalar[S, V any](q Scalar[S, V], predicates ...expr.HavingPredicate[S]) Scalar[S, V]

HavingScalar appends group predicates inside the scalar SELECT. Example: rows.HavingScalar(selected, expr.GtValue(count, 0)).

func LimitScalar

func LimitScalar[S, V any](q Scalar[S, V], n int) Scalar[S, V]

LimitScalar replaces the inner limit without changing scalar cardinality rules. Example: rows.LimitScalar(selected, 1).

func OffsetScalar

func OffsetScalar[S, V any](q Scalar[S, V], n int) Scalar[S, V]

OffsetScalar replaces the offset inside the scalar SELECT. Example: rows.OffsetScalar(selected, 1).

func OrderScalar

func OrderScalar[S, V any](q Scalar[S, V], orders ...expr.ProjectionOrder[S]) Scalar[S, V]

OrderScalar appends row or selected ordering inside the scalar SELECT. Example: rows.OrderScalar(selected, expr.Asc(age)).

func SelectScalar

func SelectScalar[S, V any](source SelectionSource[S], selected expr.Selected[S, V]) Scalar[S, V]

SelectScalar selects one exact value for scalar, IN or EXISTS composition. Example: rows.SelectScalar(rows.From(q),expr.AsSelected(expr.Row(expr.Value(orm.NumberExpr(Users.Age))))).

func WhereScalar

func WhereScalar[S, V any](q Scalar[S, V], predicates ...expr.Predicate[S]) Scalar[S, V]

WhereScalar appends row predicates without changing the selected type. Example: rows.WhereScalar(inner,expr.Eq(age, 18)).

type Schema

type Schema[R any] interface {
	// contains filtered or unexported methods
}

Schema retains a complete row declaration. Example: rows.Select(joined,OrderRows,mappings...).

type ScopeSource

type ScopeSource[S any] interface {
	// contains filtered or unexported methods
}

ScopeSource exposes enclosing visibility without granting execution. Example: rows.Correlate(parent,child).

type SelectionSource

type SelectionSource[S any] interface {
	// contains filtered or unexported methods
}

SelectionSource retains a scope for projections and subqueries, without granting join access. Example: rows.SelectScalar(rows.From(query), expr.AsSelected(expr.Row(age))).

type Set

type Set[R any] struct {
	// contains filtered or unexported fields
}

Set is the combined output scope, separate from both inputs. Example: expr.Scope[rows.Set[User],User].

type SetQuery

type SetQuery[R any] struct {
	// contains filtered or unexported fields
}

SetQuery combines complete records without model mutation methods. Example: rows.Union(rows.ModelRecord(a),rows.ModelRecord(b)).

func DistinctSet

func DistinctSet[R any](q SetQuery[R]) SetQuery[R]

DistinctSet removes duplicate combined records, preserving both input SELECTs. Example: rows.DistinctSet(rows.UnionAll(left, right)).

func Except

func Except[R any](a, b RecordSource[R]) SetQuery[R]

Except keeps distinct left rows absent on the right, retaining each input window. Example: rows.Except(a,b).

func ExceptAll

func ExceptAll[R any](a, b RecordSource[R]) SetQuery[R]

ExceptAll subtracts right multiplicities from the left, retaining each input window. Example: rows.ExceptAll(a,b).

func Intersect

func Intersect[R any](a, b RecordSource[R]) SetQuery[R]

Intersect keeps distinct rows present in both inputs, retaining each input window. Example: rows.Intersect(a,b).

func IntersectAll

func IntersectAll[R any](a, b RecordSource[R]) SetQuery[R]

IntersectAll keeps the smaller shared multiplicity, retaining each input window. Example: rows.IntersectAll(a,b).

func Union

func Union[R any](a, b RecordSource[R]) SetQuery[R]

Union removes duplicate rows, retaining each input window. Example: rows.Union(a,b).

func UnionAll

func UnionAll[R any](a, b RecordSource[R]) SetQuery[R]

UnionAll retains duplicate rows, retaining each input window. Example: rows.UnionAll(a,b).

func (SetQuery[R]) Limit

func (q SetQuery[R]) Limit(n int) SetQuery[R]

Limit bounds the combined window. Example: combined.Limit(10).

func (SetQuery[R]) Offset

func (q SetQuery[R]) Offset(n int) SetQuery[R]

Offset skips combined rows. Example: combined.Offset(10).

func (SetQuery[R]) OrderBy

func (q SetQuery[R]) OrderBy(os ...expr.ProjectionOrder[Set[R]]) SetQuery[R]

OrderBy orders combined rows independently of input ordering. Example: combined.OrderBy(expr.Asc(id)).

func (SetQuery[R]) Scope

func (q SetQuery[R]) Scope() expr.Scope[Set[R], R]

Scope exposes only the combined record's fields. Example: expr.At(combined.Scope(), orm.KeyExpr(Users.ID)).

func (SetQuery[R]) Where

func (q SetQuery[R]) Where(ps ...expr.Predicate[Set[R]]) SetQuery[R]

Where filters combined rows. Example: combined.Where(expr.Ne(expr.At(combined.Scope(), orm.KeyExpr(Users.ID)), id)).

type Source

type Source[S any] interface {
	SelectionSource[S]
	// contains filtered or unexported methods
}

Source accepts an alias or join chain in S with a preserved join boundary. Example: rows.LeftJoin(users, orders, on).

type TransactionAlias

type TransactionAlias[A, R any] struct {
	// contains filtered or unexported fields
}

TransactionAlias gives transaction-owned fields a distinct scope from ordinary aliases. Example: TransactionAlias[claimed,Order].

type TransactionAliased

type TransactionAliased[A, R any] struct {
	// contains filtered or unexported fields
}

TransactionAliased names one complete record without ordinary source methods. Example: rows.AsTransaction[claimed](record,"claimed").

func AsTransaction

func AsTransaction[A, R any](source TransactionRecordSource[R], alias string) TransactionAliased[A, R]

AsTransaction retains locks within the aliased SELECT and its executor kind. Example: rows.AsTransaction[claimed](rows.LockedRecord(orm.Lock(q)),"claimed").

type TransactionCommonTable

type TransactionCommonTable[R any] struct {
	// contains filtered or unexported fields
}

TransactionCommonTable retains a complete record's transaction requirement and locks. Example: rows.AsTransaction[tag](cte,"claim").

func TransactionCTE

func TransactionCTE[R any](name string, source TransactionRecordSource[R]) TransactionCommonTable[R]

TransactionCTE names a transaction-required complete record. Example: rows.TransactionCTE("claimed",rows.LockedRecord(orm.Lock(Orders.Query()))).

func (TransactionCommonTable[R]) Materialized

func (c TransactionCommonTable[R]) Materialized() TransactionCommonTable[R]

Materialized retains the executor requirement. Example: cte.Materialized().

func (TransactionCommonTable[R]) NotMaterialized

func (c TransactionCommonTable[R]) NotMaterialized() TransactionCommonTable[R]

NotMaterialized retains all locks even when PostgreSQL ignores the hint. Example: cte.NotMaterialized().

type TransactionCorrelatedRecord

type TransactionCorrelatedRecord[O, I TransactionScopeType, R any] struct {
	// contains filtered or unexported fields
}

TransactionCorrelatedRecord keeps a complete record bound to its enclosing scope. Example: rows.SelectTransactionCorrelatedRecord(c,rows.TransactionInnerScope(c,scope)).

func ProjectTransactionCorrelated

func ProjectTransactionCorrelated[O, I TransactionScopeType, R any](c TransactionCorrelatedSource[O, I], schema Schema[R], mappings ...Mapping[TransactionCorrelation[O, I], R]) TransactionCorrelatedRecord[O, I, R]

ProjectTransactionCorrelated maps a complete declared record without granting execution. Example: rows.ProjectTransactionCorrelated(c,Totals,rows.MapSelected(Totals.Count,count)).

func SelectTransactionCorrelatedRecord

func SelectTransactionCorrelatedRecord[O, I TransactionScopeType, R any](c TransactionCorrelatedSource[O, I], scope expr.Scope[TransactionCorrelation[O, I], R]) TransactionCorrelatedRecord[O, I, R]

SelectTransactionCorrelatedRecord selects a complete preserved inner model. Example: rows.SelectTransactionCorrelatedRecord(c,rows.TransactionInnerScope(c,rows.TransactionScope(child))).

func (TransactionCorrelatedRecord[O, I, R]) Distinct

func (r TransactionCorrelatedRecord[O, I, R]) Distinct() TransactionCorrelatedRecord[O, I, R]

Distinct retains the correlated result clause. Example: selected.Distinct().

func (TransactionCorrelatedRecord[O, I, R]) DistinctOn

func (r TransactionCorrelatedRecord[O, I, R]) DistinctOn(keys ...expr.GroupKey[TransactionCorrelation[O, I]]) TransactionCorrelatedRecord[O, I, R]

DistinctOn retains the correlated result clause. Example: selected.DistinctOn(clause).

func (TransactionCorrelatedRecord[O, I, R]) DistinctOnValues

func (r TransactionCorrelatedRecord[O, I, R]) DistinctOnValues(keys ...expr.ProjectionKey[TransactionCorrelation[O, I]]) TransactionCorrelatedRecord[O, I, R]

DistinctOnValues retains the correlated result clause. Example: selected.DistinctOnValues(clause).

func (TransactionCorrelatedRecord[O, I, R]) Exists

func (r TransactionCorrelatedRecord[O, I, R]) Exists() expr.Predicate[O]

Exists tests the record within its required outer scope. Example: record.Exists().

func (TransactionCorrelatedRecord[O, I, R]) ForKeyShare

func (q TransactionCorrelatedRecord[O, I, R]) ForKeyShare() TransactionCorrelatedRecord[O, I, R]

ForKeyShare retains this correlated SELECT’s lock without execution. Example: selected.ForKeyShare().

func (TransactionCorrelatedRecord[O, I, R]) ForNoKeyUpdate

func (q TransactionCorrelatedRecord[O, I, R]) ForNoKeyUpdate() TransactionCorrelatedRecord[O, I, R]

ForNoKeyUpdate retains this correlated SELECT’s lock without execution. Example: selected.ForNoKeyUpdate().

func (TransactionCorrelatedRecord[O, I, R]) ForShare

func (q TransactionCorrelatedRecord[O, I, R]) ForShare() TransactionCorrelatedRecord[O, I, R]

ForShare retains this correlated SELECT’s lock without execution. Example: selected.ForShare().

func (TransactionCorrelatedRecord[O, I, R]) ForUpdate

func (q TransactionCorrelatedRecord[O, I, R]) ForUpdate() TransactionCorrelatedRecord[O, I, R]

ForUpdate retains this correlated SELECT’s lock without execution. Example: selected.ForUpdate().

func (TransactionCorrelatedRecord[O, I, R]) GroupBy

GroupBy retains the correlated result clause. Example: selected.GroupBy(clause).

func (TransactionCorrelatedRecord[O, I, R]) Having

Having retains the correlated result clause. Example: selected.Having(clause).

func (TransactionCorrelatedRecord[O, I, R]) Limit

func (r TransactionCorrelatedRecord[O, I, R]) Limit(n int) TransactionCorrelatedRecord[O, I, R]

Limit retains the record's inner limit. Example: record.Limit(1).

func (TransactionCorrelatedRecord[O, I, R]) LockRows

LockRows sets independent preserved-input locks. Example: selected.LockRows(rows.ShareLock(target)).

func (TransactionCorrelatedRecord[O, I, R]) NoWait

func (q TransactionCorrelatedRecord[O, I, R]) NoWait() TransactionCorrelatedRecord[O, I, R]

NoWait derives an existing lock policy. Example: selected.ForUpdate().NoWait().

func (TransactionCorrelatedRecord[O, I, R]) Of

Of narrows one existing lock to preserved scopes. Example: selected.ForUpdate().Of(target).

func (TransactionCorrelatedRecord[O, I, R]) Offset

func (r TransactionCorrelatedRecord[O, I, R]) Offset(n int) TransactionCorrelatedRecord[O, I, R]

Offset retains the record's inner offset. Example: record.Offset(1).

func (TransactionCorrelatedRecord[O, I, R]) OrderBy

OrderBy appends inner result ordering. Example: record.OrderBy(expr.Desc(childID)).

func (TransactionCorrelatedRecord[O, I, R]) SkipLocked

func (q TransactionCorrelatedRecord[O, I, R]) SkipLocked() TransactionCorrelatedRecord[O, I, R]

SkipLocked derives an existing lock policy. Example: selected.ForUpdate().SkipLocked().

func (TransactionCorrelatedRecord[O, I, R]) Wait

func (q TransactionCorrelatedRecord[O, I, R]) Wait() TransactionCorrelatedRecord[O, I, R]

Wait derives an existing lock policy. Example: selected.ForUpdate().Wait().

func (TransactionCorrelatedRecord[O, I, R]) Where

Where appends lifted inner predicates. Example: record.Where(expr.Equal(childID,parentID)).

type TransactionCorrelatedScalar

type TransactionCorrelatedScalar[O, I TransactionScopeType, V any] struct {
	// contains filtered or unexported fields
}

TransactionCorrelatedScalar keeps one value bound to its enclosing scope. Example: rows.SelectTransactionCorrelatedScalar(c,expr.AsSelected(expr.Row(childID))).

func SelectTransactionCorrelatedScalar

func SelectTransactionCorrelatedScalar[O, I TransactionScopeType, V any](c TransactionCorrelatedSource[O, I], v expr.Selected[TransactionCorrelation[O, I], V]) TransactionCorrelatedScalar[O, I, V]

SelectTransactionCorrelatedScalar selects one lifted value without an execution escape. Example: rows.SelectTransactionCorrelatedScalar(c,expr.AsSelected(expr.Row(childID))).

func (TransactionCorrelatedScalar[O, I, V]) Exists

func (s TransactionCorrelatedScalar[O, I, V]) Exists() expr.Predicate[O]

Exists tests the selected result in the enclosing scope. Example: selected.Limit(0).Exists().

func (TransactionCorrelatedScalar[O, I, V]) ForKeyShare

func (q TransactionCorrelatedScalar[O, I, V]) ForKeyShare() TransactionCorrelatedScalar[O, I, V]

ForKeyShare retains this correlated SELECT’s lock without execution. Example: selected.ForKeyShare().

func (TransactionCorrelatedScalar[O, I, V]) ForNoKeyUpdate

func (q TransactionCorrelatedScalar[O, I, V]) ForNoKeyUpdate() TransactionCorrelatedScalar[O, I, V]

ForNoKeyUpdate retains this correlated SELECT’s lock without execution. Example: selected.ForNoKeyUpdate().

func (TransactionCorrelatedScalar[O, I, V]) ForShare

func (q TransactionCorrelatedScalar[O, I, V]) ForShare() TransactionCorrelatedScalar[O, I, V]

ForShare retains this correlated SELECT’s lock without execution. Example: selected.ForShare().

func (TransactionCorrelatedScalar[O, I, V]) ForUpdate

func (q TransactionCorrelatedScalar[O, I, V]) ForUpdate() TransactionCorrelatedScalar[O, I, V]

ForUpdate retains this correlated SELECT’s lock without execution. Example: selected.ForUpdate().

func (TransactionCorrelatedScalar[O, I, V]) GroupBy

GroupBy retains the correlated result clause. Example: selected.GroupBy(clause).

func (TransactionCorrelatedScalar[O, I, V]) Having

Having retains the correlated result clause. Example: selected.Having(clause).

func (TransactionCorrelatedScalar[O, I, V]) Limit

func (s TransactionCorrelatedScalar[O, I, V]) Limit(n int) TransactionCorrelatedScalar[O, I, V]

Limit retains an explicit inner limit. Example: selected.Limit(1).

func (TransactionCorrelatedScalar[O, I, V]) LockRows

LockRows sets independent preserved-input locks. Example: selected.LockRows(rows.ShareLock(target)).

func (TransactionCorrelatedScalar[O, I, V]) NoWait

func (q TransactionCorrelatedScalar[O, I, V]) NoWait() TransactionCorrelatedScalar[O, I, V]

NoWait derives an existing lock policy. Example: selected.ForUpdate().NoWait().

func (TransactionCorrelatedScalar[O, I, V]) Of

Of narrows one existing lock to preserved scopes. Example: selected.ForUpdate().Of(target).

func (TransactionCorrelatedScalar[O, I, V]) Offset

func (s TransactionCorrelatedScalar[O, I, V]) Offset(n int) TransactionCorrelatedScalar[O, I, V]

Offset retains an explicit inner offset. Example: selected.Offset(1).

func (TransactionCorrelatedScalar[O, I, V]) OrderBy

OrderBy appends inner ordering. Example: selected.OrderBy(expr.Desc(childID)).

func (TransactionCorrelatedScalar[O, I, V]) SkipLocked

func (q TransactionCorrelatedScalar[O, I, V]) SkipLocked() TransactionCorrelatedScalar[O, I, V]

SkipLocked derives an existing lock policy. Example: selected.ForUpdate().SkipLocked().

func (TransactionCorrelatedScalar[O, I, V]) Wait

func (q TransactionCorrelatedScalar[O, I, V]) Wait() TransactionCorrelatedScalar[O, I, V]

Wait derives an existing lock policy. Example: selected.ForUpdate().Wait().

func (TransactionCorrelatedScalar[O, I, V]) Where

Where filters the inner SELECT with lifted predicates. Example: selected.Where(expr.Equal(childID,parentID)).

type TransactionCorrelatedSource

type TransactionCorrelatedSource[O, I TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionCorrelatedSource retains its enclosing scope and cannot execute independently. Example: rows.TransactionCorrelate(parent,child).

func TransactionCorrelate

TransactionCorrelate makes only the supplied enclosing scopes visible inside inner. Example: rows.TransactionCorrelate(parent,child).

func (TransactionCorrelatedSource[O, I]) Exists

func (c TransactionCorrelatedSource[O, I]) Exists() expr.Predicate[O]

Exists returns a predicate in the enclosing scope. Example: expr.Where(users,c.Exists()).

func (TransactionCorrelatedSource[O, I]) Limit

Limit retains an inner result limit. Example: c.Limit(1).

func (TransactionCorrelatedSource[O, I]) Offset

Offset retains an inner result offset. Example: c.Offset(1).

func (TransactionCorrelatedSource[O, I]) OrderBy

OrderBy appends scoped ordering. Example: c.OrderBy(expr.Desc(childID)).

func (TransactionCorrelatedSource[O, I]) Where

Where appends predicates in the lifted correlation scope. Example: c.Where(expr.Equal(childID,parentID)).

type TransactionCorrelation

type TransactionCorrelation[O, I TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionCorrelation identifies an explicit enclosing/inner scope pair. Example: TransactionCorrelation[TransactionAlias[parent,User],TransactionAlias[child,Order]].

type TransactionCross

type TransactionCross[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionCross identifies a transaction-only cross join scope. Example: rows.TransactionCross[L,R].

type TransactionCrossJoined

type TransactionCrossJoined[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionCrossJoined retains both input boundaries and their nested locks. Example: rows.TransactionCrossJoin(left,right).

func TransactionCrossJoin

func TransactionCrossJoin[L, R TransactionScopeType](left TransactionJoinSource[L], right TransactionJoinTable[R]) TransactionCrossJoined[L, R]

TransactionCrossJoin preserves filters, windows and locks at each alias boundary. Example: rows.TransactionCrossJoin(left,right).

func TransactionCrossJoinLateral

func TransactionCrossJoinLateral[L TransactionScopeType, A, R any](left TransactionJoinSource[L], right TransactionLateralSource[A, L, R]) TransactionCrossJoined[L, TransactionAlias[A, R]]

TransactionCrossJoinLateral evaluates right for each preceding left row. Example: rows.TransactionCrossJoinLateral(parent,latest).

type TransactionFull

type TransactionFull[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionFull identifies a transaction-only full join scope. Example: rows.TransactionFull[L,R].

type TransactionFullJoined

type TransactionFullJoined[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionFullJoined retains both input boundaries and their nested locks. Example: rows.TransactionFullJoin(left,right,on).

func TransactionFullJoin

func TransactionFullJoin[L, R TransactionScopeType](left TransactionJoinSource[L], right TransactionJoinTable[R], on JoinOn[L, R]) TransactionFullJoined[L, R]

TransactionFullJoin preserves filters, windows and locks at each alias boundary. Example: rows.TransactionFullJoin(left,right,on).

type TransactionInner

type TransactionInner[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionInner identifies a transaction-only inner join scope. Example: rows.TransactionInner[L,R].

type TransactionInnerJoined

type TransactionInnerJoined[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionInnerJoined retains both input boundaries and their nested locks. Example: rows.TransactionInnerJoin(left,right,on).

func TransactionInnerJoin

func TransactionInnerJoin[L, R TransactionScopeType](left TransactionJoinSource[L], right TransactionJoinTable[R], on JoinOn[L, R]) TransactionInnerJoined[L, R]

TransactionInnerJoin preserves filters, windows and locks at each alias boundary. Example: rows.TransactionInnerJoin(left,right,on).

func TransactionInnerJoinLateral

func TransactionInnerJoinLateral[L TransactionScopeType, A, R any](left TransactionJoinSource[L], right TransactionLateralSource[A, L, R], on ...JoinOn[L, TransactionAlias[A, R]]) TransactionInnerJoined[L, TransactionAlias[A, R]]

TransactionInnerJoinLateral combines optional typed ON conditions; no conditions means ON TRUE. Example: rows.TransactionInnerJoinLateral(parent,latest).

type TransactionJoinSource

type TransactionJoinSource[S TransactionScopeType] interface{ TransactionSelectionSource[S] }

TransactionJoinSource retains transaction scope and complete alias boundaries. Example: rows.TransactionLeftJoin(users,orders,on).

type TransactionJoinTable

type TransactionJoinTable[S TransactionScopeType] interface {
	TransactionJoinSource[S]
	// contains filtered or unexported methods
}

TransactionJoinTable admits a single transaction alias on a join's right side. Example: rows.TransactionInnerJoin(users,orders,on).

type TransactionLateralSource

type TransactionLateralSource[A any, O TransactionScopeType, R any] struct {
	// contains filtered or unexported fields
}

TransactionLateralSource retains its required preceding scope without ordinary source methods. Example: rows.AsTransactionLateral[latest](record,"latest").

func AsTransactionLateral

func AsTransactionLateral[A any, O, I TransactionScopeType, R any](record TransactionCorrelatedRecord[O, I, R], alias string) TransactionLateralSource[A, O, R]

AsTransactionLateral always creates a derived SELECT for a correlated record. Example: rows.AsTransactionLateral[latest](record.Limit(1),"latest").

type TransactionLeft

type TransactionLeft[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionLeft identifies a transaction-only left join scope. Example: rows.TransactionLeft[L,R].

type TransactionLeftJoined

type TransactionLeftJoined[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionLeftJoined retains both input boundaries and their nested locks. Example: rows.TransactionLeftJoin(left,right,on).

func TransactionLeftJoin

func TransactionLeftJoin[L, R TransactionScopeType](left TransactionJoinSource[L], right TransactionJoinTable[R], on JoinOn[L, R]) TransactionLeftJoined[L, R]

TransactionLeftJoin preserves filters, windows and locks at each alias boundary. Example: rows.TransactionLeftJoin(left,right,on).

func TransactionLeftJoinLateral

func TransactionLeftJoinLateral[L TransactionScopeType, A, R any](left TransactionJoinSource[L], right TransactionLateralSource[A, L, R], on ...JoinOn[L, TransactionAlias[A, R]]) TransactionLeftJoined[L, TransactionAlias[A, R]]

TransactionLeftJoinLateral preserves unmatched parents and widens the right scope. Example: rows.TransactionLeftJoinLateral(parent,latest).

type TransactionRead

type TransactionRead[S, R any] struct {
	// contains filtered or unexported fields
}

TransactionRead returns a complete result only through a transaction executor. Example: selected.All(ctx,tx).

func SelectTransaction

func SelectTransaction[S, R any](source TransactionSelectionSource[S], schema Schema[R], mappings ...Mapping[S, R]) TransactionRead[S, R]

SelectTransaction reuses complete projection mapping and declaration validation. Example: rows.SelectTransaction(source,Summary,rows.Map(Summary.ID,id)).

func SelectTransactionRecord

func SelectTransactionRecord[S, R any](source TransactionSelectionSource[S], scope expr.Scope[S, R]) TransactionRead[S, R]

SelectTransactionRecord selects every field from a preserved transaction scope. Example: rows.SelectTransactionRecord(source,rows.TransactionScope(source)).

func (TransactionRead[S, R]) All

func (q TransactionRead[S, R]) All(ctx context.Context, tx *database.Tx) ([]R, error)

All requires the caller's transaction and discards every partial result on error. Example: selected.All(ctx,tx).

func (TransactionRead[S, R]) Count

func (q TransactionRead[S, R]) Count(ctx context.Context, ex *database.Tx) (int64, error)

Count counts the selected window, preserving nested locks. Example: selected.Count(ctx,executor).

func (TransactionRead[S, R]) Exists

func (q TransactionRead[S, R]) Exists(ctx context.Context, ex *database.Tx) (bool, error)

Exists tests the selected window. Example: selected.Exists(ctx,executor).

func (TransactionRead[S, R]) First

func (q TransactionRead[S, R]) First(ctx context.Context, ex *database.Tx) (value.Optional[R], error)

First returns an omitted optional for an empty result. Example: selected.First(ctx,executor).

func (TransactionRead[S, R]) Limit

func (q TransactionRead[S, R]) Limit(n int) TransactionRead[S, R]

Limit retains the transaction selection's window. Example: selected.Limit(10).

func (TransactionRead[S, R]) Offset

func (q TransactionRead[S, R]) Offset(n int) TransactionRead[S, R]

Offset retains the transaction selection's offset. Example: selected.Offset(10).

func (TransactionRead[S, R]) OrderBy

func (q TransactionRead[S, R]) OrderBy(os ...expr.ProjectionOrder[S]) TransactionRead[S, R]

OrderBy orders the transaction selection. Example: selected.OrderBy(expr.Asc(id)).

func (TransactionRead[S, R]) RequireFirst

func (q TransactionRead[S, R]) RequireFirst(ctx context.Context, ex *database.Tx) (R, error)

RequireFirst reports database.NotFound for an empty result. Example: selected.RequireFirst(ctx,executor).

func (TransactionRead[S, R]) Where

func (q TransactionRead[S, R]) Where(ps ...expr.Predicate[S]) TransactionRead[S, R]

Where retains transaction input ownership. Example: selected.Where(expr.Gt(id, 0)).

type TransactionRecord

type TransactionRecord[R any] struct {
	// contains filtered or unexported fields
}

TransactionRecord explicitly retains the transaction requirement, without execution. Example: rows.TransactionOf(rows.ModelRecord(Users.Query())).

func LockedRecord

func LockedRecord[M any](q orm.LockedQuery[M]) TransactionRecord[M]

LockedRecord retains all model locks and their wait policy inside the source. Example: rows.LockedRecord(orm.Lock(Users.Query()).SkipLocked()).

func TransactionOf

func TransactionOf[R any](source RecordSource[R]) TransactionRecord[R]

TransactionOf lifts an ordinary complete record into transaction composition. Example: rows.TransactionOf(rows.RecordOf(report)).

type TransactionRecordSource

type TransactionRecordSource[R any] interface {
	// contains filtered or unexported methods
}

TransactionRecordSource carries complete results and nested locks in one getter. Example: rows.AsTransaction[tag](rows.LockedRecord(orm.Lock(q)),"claim").

type TransactionRight

type TransactionRight[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionRight identifies a transaction-only right join scope. Example: rows.TransactionRight[L,R].

type TransactionRightJoined

type TransactionRightJoined[L, R TransactionScopeType] struct {
	// contains filtered or unexported fields
}

TransactionRightJoined retains both input boundaries and their nested locks. Example: rows.TransactionRightJoin(left,right,on).

func TransactionRightJoin

func TransactionRightJoin[L, R TransactionScopeType](left TransactionJoinSource[L], right TransactionJoinTable[R], on JoinOn[L, R]) TransactionRightJoined[L, R]

TransactionRightJoin preserves filters, windows and locks at each alias boundary. Example: rows.TransactionRightJoin(left,right,on).

type TransactionScalar

type TransactionScalar[S TransactionScopeType, V any] struct {
	// contains filtered or unexported fields
}

TransactionScalar retains a selected value and optional locks for composition only. Example: rows.TransactionScalarOf(selected).ForUpdate().SkipLocked().

func TransactionScalarOf

func TransactionScalarOf[S TransactionScopeType, V any](q TransactionValue[S, V]) TransactionScalar[S, V]

TransactionScalarOf retains codecs when adding locks to scalar subqueries. Example: rows.TransactionScalarOf(rows.SelectTransactionValue(source,expr.AsSelected(expr.Row(id)))).ForShare().

func (TransactionScalar[S, V]) ForKeyShare

func (q TransactionScalar[S, V]) ForKeyShare() TransactionScalar[S, V]

ForKeyShare retains a scalar SELECT lock for composition. Example: rows.TransactionScalarOf(selected).ForKeyShare().

func (TransactionScalar[S, V]) ForNoKeyUpdate

func (q TransactionScalar[S, V]) ForNoKeyUpdate() TransactionScalar[S, V]

ForNoKeyUpdate retains a scalar SELECT lock for composition. Example: rows.TransactionScalarOf(selected).ForNoKeyUpdate().

func (TransactionScalar[S, V]) ForShare

func (q TransactionScalar[S, V]) ForShare() TransactionScalar[S, V]

ForShare retains a scalar SELECT lock for composition. Example: rows.TransactionScalarOf(selected).ForShare().

func (TransactionScalar[S, V]) ForUpdate

func (q TransactionScalar[S, V]) ForUpdate() TransactionScalar[S, V]

ForUpdate retains a scalar SELECT lock for composition. Example: rows.TransactionScalarOf(selected).ForUpdate().

func (TransactionScalar[S, V]) LockRows

func (q TransactionScalar[S, V]) LockRows(cs ...RowLock[S]) TransactionScalar[S, V]

LockRows applies independent locks to a scalar subquery. Example: selected.LockRows(rows.ShareLock(target)).

func (TransactionScalar[S, V]) NoWait

func (q TransactionScalar[S, V]) NoWait() TransactionScalar[S, V]

NoWait derives an existing scalar lock policy. Example: selected.ForUpdate().NoWait().

func (TransactionScalar[S, V]) Of

func (q TransactionScalar[S, V]) Of(ts ...LockTarget[S]) TransactionScalar[S, V]

Of narrows one scalar lock to preserved inputs. Example: selected.ForUpdate().Of(target).

func (TransactionScalar[S, V]) SkipLocked

func (q TransactionScalar[S, V]) SkipLocked() TransactionScalar[S, V]

SkipLocked derives an existing scalar lock policy. Example: selected.ForUpdate().SkipLocked().

func (TransactionScalar[S, V]) Wait

func (q TransactionScalar[S, V]) Wait() TransactionScalar[S, V]

Wait derives an existing scalar lock policy. Example: selected.ForUpdate().Wait().

type TransactionScopeSource

type TransactionScopeSource[S TransactionScopeType] interface {
	// contains filtered or unexported methods
}

TransactionScopeSource exposes enclosing visibility without granting execution. Example: rows.TransactionCorrelate(parent,child).

type TransactionScopeType

type TransactionScopeType interface {
	// contains filtered or unexported methods
}

TransactionScopeType identifies scopes whose composition requires a transaction. Example: rows.TransactionInner[rows.TransactionAlias[a,User],rows.TransactionAlias[b,Order]].

type TransactionSelectionSource

type TransactionSelectionSource[S any] interface {
	// contains filtered or unexported methods
}

TransactionSelectionSource exposes only transaction-required input scopes. Example: rows.SelectTransaction(source,Summary,mappings...).

type TransactionSubquery

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

TransactionSubquery explicitly lifts an ordinary SELECT for transaction composition. Example: rows.TransactionSubqueryOf(rows.From(Users.Query())).

func TransactionSubqueryOf

func TransactionSubqueryOf[S any](source SelectionSource[S]) TransactionSubquery

TransactionSubqueryOf preserves all clauses of an ordinary SELECT. Example: rows.TransactionSubqueryOf(rows.FromRows(report)).

type TransactionSubquerySource

type TransactionSubquerySource interface {
	// contains filtered or unexported methods
}

TransactionSubquerySource retains a SELECT without permitting ordinary execution. Example: rows.TransactionExistsQuery(parent,child).

type TransactionValue

type TransactionValue[S, V any] struct {
	// contains filtered or unexported fields
}

TransactionValue is a scalar result executable only through a transaction. Example: selected.First(ctx,tx).

func SelectTransactionValue

func SelectTransactionValue[S, V any](source TransactionSelectionSource[S], selected expr.Selected[S, V]) TransactionValue[S, V]

SelectTransactionValue retains exact scalar codecs and the transaction requirement. Example: rows.SelectTransactionValue(source,expr.AsSelected(expr.Row(id))).All(ctx,tx).

func (TransactionValue[S, V]) All

func (q TransactionValue[S, V]) All(ctx context.Context, ex *database.Tx) ([]V, error)

All collects complete results or discards the entire batch. Example: selected.All(ctx,executor).

func (TransactionValue[S, V]) Count

func (q TransactionValue[S, V]) Count(ctx context.Context, ex *database.Tx) (int64, error)

Count counts the selected window, preserving nested locks. Example: selected.Count(ctx,executor).

func (TransactionValue[S, V]) Exists

func (q TransactionValue[S, V]) Exists(ctx context.Context, ex *database.Tx) (bool, error)

Exists tests the selected window. Example: selected.Exists(ctx,executor).

func (TransactionValue[S, V]) First

func (q TransactionValue[S, V]) First(ctx context.Context, ex *database.Tx) (value.Optional[V], error)

First returns an omitted optional for an empty result. Example: selected.First(ctx,executor).

func (TransactionValue[S, V]) Limit

func (q TransactionValue[S, V]) Limit(n int) TransactionValue[S, V]

Limit bounds selected rows. Example: selected.Limit(10).

func (TransactionValue[S, V]) Offset

func (q TransactionValue[S, V]) Offset(n int) TransactionValue[S, V]

Offset skips selected rows. Example: selected.Offset(10).

func (TransactionValue[S, V]) OrderBy

func (q TransactionValue[S, V]) OrderBy(os ...expr.ProjectionOrder[S]) TransactionValue[S, V]

OrderBy retains explicit result ordering. Example: selected.OrderBy(expr.Asc(id)).

func (TransactionValue[S, V]) RequireFirst

func (q TransactionValue[S, V]) RequireFirst(ctx context.Context, ex *database.Tx) (V, error)

RequireFirst reports database.NotFound for an empty result. Example: selected.RequireFirst(ctx,executor).

func (TransactionValue[S, V]) Where

func (q TransactionValue[S, V]) Where(ps ...expr.Predicate[S]) TransactionValue[S, V]

Where filters the retained input scope. Example: selected.Where(expr.Ne(id, zero)).

type TransactionValueInput

type TransactionValueInput[V any] struct {
	// contains filtered or unexported fields
}

TransactionValueInput lifts an ordinary single-column source without execution. Example: rows.TransactionValueOf(rows.Values(selected)).

func TransactionValueOf

func TransactionValueOf[V any](source ValueSource[V]) TransactionValueInput[V]

TransactionValueOf retains an ordinary scalar's codec, clauses and sensitivity. Example: rows.TransactionInQuery(id,rows.TransactionValueOf(rows.Values(selected))).

type TransactionValueSource

type TransactionValueSource[V any] interface {
	// contains filtered or unexported methods
}

TransactionValueSource retains a single value's exact codec and executor requirement. Example: expr.AsSelected(rows.TransactionScalarRowQuery(parent, selected)).

type ValueCursorQuery

type ValueCursorQuery[V any] struct {
	// contains filtered or unexported fields
}

ValueCursorQuery pages one exact scalar type, including nullable results. Example: rows.ValueCursorFor(rows.Values(selected)).

func ValueCursorFor

func ValueCursorFor[V any](source ValueSource[V]) ValueCursorQuery[V]

ValueCursorFor preserves duplicates; UniqueBy is the caller's uniqueness assertion. Example: rows.ValueCursorFor(rows.UnionValues(a,b)).

func (ValueCursorQuery[V]) OrderBy

OrderBy orders plain output fields. Example: c.OrderBy(expr.Asc(id)).

func (ValueCursorQuery[V]) Paginate

Paginate reads one lookahead row; tokens are positions, not authorization. Example: c.Paginate(ctx,db,orm.CursorRequest[V]{Size:20}).

func (ValueCursorQuery[V]) Scope

func (q ValueCursorQuery[V]) Scope() expr.Scope[CursorScope[V], V]

Scope exposes completed output fields. Example: expr.At(c.Scope(), orm.KeyExpr(Users.ID)).

func (ValueCursorQuery[V]) UniqueBy

func (q ValueCursorQuery[V]) UniqueBy(keys ...expr.GroupKey[CursorScope[V]]) ValueCursorQuery[V]

UniqueBy asserts result uniqueness and appends missing identity orders. Example: c.UniqueBy(expr.Group(id)).

func (ValueCursorQuery[V]) Value

func (q ValueCursorQuery[V]) Value() expr.RowExpression[CursorScope[V], V]

Value exposes the completed scalar for filtering and ordering. Example: expr.Asc(c.Value()).

func (ValueCursorQuery[V]) Where

func (q ValueCursorQuery[V]) Where(ps ...expr.Predicate[CursorScope[V]]) ValueCursorQuery[V]

Where filters completed rows. Example: c.Where(expr.Ne(id, zero)).

type ValueRecord

type ValueRecord[V any] struct {
	// contains filtered or unexported fields
}

ValueRecord adapts one selected scalar without widening its type or granting record access. Example: rows.Values(rows.SelectScalar(source,expr.AsSelected(expr.Row(id)))).

func Values

func Values[S, V any](q Scalar[S, V]) ValueRecord[V]

Values adapts a typed scalar selection for value set operations. Example: rows.Values(rows.SelectScalar(rows.From(Users.Query()),expr.AsSelected(expr.Row(expr.Value(orm.KeyExpr(Users.ID)))))).

type ValueSetQuery

type ValueSetQuery[V any] struct {
	// contains filtered or unexported fields
}

ValueSetQuery retains one exact scalar type in the combined output scope. Example: rows.ReadValues(values.Where(expr.Ne(values.Value(), id))).All(ctx,db).

func DistinctOnValueSet

func DistinctOnValueSet[V any](q ValueSetQuery[V], keys ...expr.ProjectionKey[Set[V]]) ValueSetQuery[V]

DistinctOnValueSet selects one combined value per selected-key combination. Keys and ordering belong to the combined output scope, not either input SELECT. Example: rows.DistinctOnValueSet(values, expr.Key(expr.AsSelected(expr.Row(values.Value())))).

func DistinctValues

func DistinctValues[V any](q ValueSetQuery[V]) ValueSetQuery[V]

DistinctValues removes duplicate combined values with their original codec. Example: rows.DistinctValues(rows.UnionAllValues(left, right)).

func ExceptAllValues

func ExceptAllValues[V any](a, b ValueSource[V]) ValueSetQuery[V]

ExceptAllValues subtracts right multiplicities from the left with an exact scalar result type. Example: rows.ExceptAllValues(a,b).

func ExceptValues

func ExceptValues[V any](a, b ValueSource[V]) ValueSetQuery[V]

ExceptValues keeps distinct left rows absent on the right with an exact scalar result type. Example: rows.ExceptValues(a,b).

func IntersectAllValues

func IntersectAllValues[V any](a, b ValueSource[V]) ValueSetQuery[V]

IntersectAllValues keeps the smaller shared multiplicity with an exact scalar result type. Example: rows.IntersectAllValues(a,b).

func IntersectValues

func IntersectValues[V any](a, b ValueSource[V]) ValueSetQuery[V]

IntersectValues keeps distinct rows present in both inputs with an exact scalar result type. Example: rows.IntersectValues(a,b).

func UnionAllValues

func UnionAllValues[V any](a, b ValueSource[V]) ValueSetQuery[V]

UnionAllValues retains duplicate rows with an exact scalar result type. Example: rows.UnionAllValues(a,b).

func UnionValues

func UnionValues[V any](a, b ValueSource[V]) ValueSetQuery[V]

UnionValues removes duplicate rows with an exact scalar result type. Example: rows.UnionValues(a,b).

func (ValueSetQuery[V]) Limit

func (q ValueSetQuery[V]) Limit(n int) ValueSetQuery[V]

Limit bounds combined values. Example: combined.Limit(10).

func (ValueSetQuery[V]) Offset

func (q ValueSetQuery[V]) Offset(n int) ValueSetQuery[V]

Offset skips combined values. Example: combined.Offset(10).

func (ValueSetQuery[V]) OrderBy

func (q ValueSetQuery[V]) OrderBy(os ...expr.ProjectionOrder[Set[V]]) ValueSetQuery[V]

OrderBy orders combined values. Example: combined.OrderBy(expr.Asc(combined.Value())).

func (ValueSetQuery[V]) Value

func (q ValueSetQuery[V]) Value() expr.RowExpression[Set[V], V]

Value exposes the combined scalar with its original codec and nullability. Example: expr.AsSelected(expr.Row(values.Value())).

func (ValueSetQuery[V]) Where

func (q ValueSetQuery[V]) Where(ps ...expr.Predicate[Set[V]]) ValueSetQuery[V]

Where filters combined values. Example: combined.Where(expr.Eq(combined.Value(), v)).

type ValueSource

type ValueSource[V any] interface {
	// contains filtered or unexported methods
}

ValueSource retains exact scalar types across set inputs. Example: rows.UnionValues(a,b).

Jump to

Keyboard shortcuts

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