Add before_acquire passthrough and idle-ping shorthand to ConnectOptions (#3143)
Expose SQLx's `before_acquire` pool hook, which SeaORM previously only
reachable through the raw `map_sqlx_<db>_pool_opts` escape hatch.
- `test_before_acquire_if_idle_for(Duration)`: DB-agnostic shorthand that
pings a pooled connection before handing it out only once it has been idle
for at least the given duration, instead of on every acquire. Sets
`test_before_acquire(false)`.
- `map_sqlx_{postgres,mysql,sqlite}_before_acquire`: per-backend passthrough of
SQLx's `before_acquire` callback.
- `get_test_before_acquire` / `get_test_before_acquire_if_idle_for` getters.
Because SQLx's single `before_acquire` slot replaces rather than composes and
has no getter, a generic `apply_before_acquire` helper composes the idle-ping
shorthand with any user-provided callback into one closure (idle-ping first,
then the user callback). The helper returns the pool options untouched when
neither option is set, so existing behavior is unchanged.
Purely additive: no existing signature, default, or behavior is changed. C
Chris Tsang committed
d612926ac331fd1d27f803cab39722a1ec626861
Parent: 2295fc1
Committed by GitHub <noreply@github.com>
on 7/23/2026, 12:47:07 PM