cratestack_sqlx/query/batch.rs
1//! Batch primitives — `batch_get`, `batch_create`, `batch_update`,
2//! `batch_delete`, `batch_upsert`.
3//!
4//! Wire shape is the tRPC-style envelope from `cratestack-core`:
5//! every request returns `Vec<BatchItemResult<M>>` where each item
6//! carries an independent `Ok(M)` or `Err(BatchItemError)`. The outer
7//! `Result` is reserved for whole-batch infrastructure failures
8//! (size cap exceeded, duplicate-input rejection, DB connection lost).
9//!
10//! Transactional model: one outer `BEGIN`, with each mutating item
11//! running in a nested `SAVEPOINT`. Per-item failures rollback to
12//! their savepoint, so failed items leave no row, no audit row, no
13//! event outbox entry. The non-mutating op (`batch_get`) and the
14//! single-statement op (`batch_delete`) don't need savepoints — the
15//! WHERE clause already filters out policy-denied / missing rows.
16//!
17//! Sizing: every request is capped at `BATCH_MAX_ITEMS` at the outer
18//! guard. Duplicate-input keys are loud-failed at the same guard.
19
20mod create;
21mod create_item;
22mod delete;
23mod get;
24mod update;
25mod update_item;
26mod upsert;
27mod upsert_item;
28mod upsert_sql;
29mod validate;
30
31pub use create::BatchCreate;
32pub use delete::BatchDelete;
33pub use get::BatchGet;
34pub use update::{BatchUpdate, BatchUpdateItem};
35pub use upsert::BatchUpsert;