Documentation
¶
Overview ¶
Package exec is the base module's execution layer — the only layer that touches database/sql at runtime. The query runners List, One, and Query take a database.Session, so the same reads run against the pool or inside a transaction; the command runners Insert, Update, and Delete take a *database.Tx, so the compiler enforces the consumer-owned transaction boundary. Every runner renders the SQL its operation would be hand-written as — never another operation's scaffolding — and every driver error routes through the session dialect's MapError, so constraint violations reach the caller as the database package's classified sentinels.
Guard outcomes ¶
The guarded runners map the operation.Guarded pair to one outcome: success returns the deterministic new version with no extra round trip; a miss runs the check, returning sql.ErrNoRows when the row is gone and database.ErrVersionMismatch — carrying the expected and current versions — when it moved. Under concurrent writers the split is best-effort (the check observes a later snapshot); it is exact under serializable isolation, and both outcomes are conflicts either way.
Index ¶
- func Delete(ctx context.Context, tx *database.Tx, del operation.GuardedDelete) error
- func List[T any](ctx context.Context, s database.Session, p operation.Projection, ...) ([]T, int, error)
- func One[T any](ctx context.Context, s database.Session, p operation.Projection, field string, ...) (T, error)
- func Query[T any](ctx context.Context, s database.Session, stmt ast.SQL, scan Scan[T]) ([]T, error)
- func Update(ctx context.Context, tx *database.Tx, u operation.GuardedUpdate) (int64, error)
- type Identity
- type Scan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List[T any]( ctx context.Context, s database.Session, p operation.Projection, dir operation.Directives, scan Scan[T], ) ([]T, int, error)
List runs the list query: the projection's count and page statements over one shared WHERE, returning the page's items and the total row count.
func One ¶
func One[T any]( ctx context.Context, s database.Session, p operation.Projection, field string, value any, scan Scan[T], ) (T, error)
One runs the single-row query. A missing row is sql.ErrNoRows; an unknown field is the operation package's typed error, surfaced before anything executes; when the filtered field is not unique, the first row wins, as with sql.DB.QueryRow.