pub async fn insert_returning(
pool: &PgPool,
query: &InsertQuery,
) -> Result<PgRow, ExecError>Expand description
Run an InsertQuery and return the row created by the
RETURNING clause.
Used by macro-generated insert paths for models with Auto<T> PKs:
the column is omitted from the INSERT (so Postgres’ BIGSERIAL
sequence fires) and the assigned value is read back via RETURNING.
Caller pulls each returned column out via sqlx::Row::try_get —
e.g. Auto<i64>::decode rebuilds an Auto::Set(value).
§Errors
Returns ExecError::EmptyReturning if query.returning is empty
(use insert for those); validation, SQL-writing, or driver
failures otherwise.