Creating the same primary key twice should fail. On DynamoDB the insert
carries an attribute_not_exists condition on the version column; on SQL
backends the primary-key constraint rejects the duplicate.
The query-based counterpart to relative_update_increments_value_and_version:
a relative assignment (value += 1) on a versioned model through a
query-rooted update.
A query-based update bumps the version, so a concurrent instance update from
a snapshot taken before the query update fails its OCC check rather than
silently clobbering the query update’s write.
Query-based update on a versioned model matching multiple rows. On DynamoDB
this exercises update_by_key path 2 (no unique index, N keys via
transact_write_items); on SQL backends it is a single multi-row UPDATE.
Query-based update through the unique-index path (path 3) increments the
version. The version is a non-unique column, so it rides along in the main
update expression alongside the unique-index surgery.
The read-back variant of update_after_delete_fails: a relative update
(increment) carries a RETURNING, so the conditional write goes through
the row-returning path. With the row deleted there is nothing to return —
the update fails rather than reloading the instance from a phantom row.
A relative update (increment) on a versioned model. The post-increment
value can’t be computed client-side, so the driver returns it; the
client-side #[version] bump rides along as a constant in the same
returning projection. The two must not collide: the engine asks the driver
for exactly the relative column, so the version value never lands in the
returned row and shifts value out of its slot.
A conditional write binding a value whose database type cannot be inferred
from the value alone (f64). Exercises bind-param type refinement through
both SQL conditional-write plans (regression: the PostgreSQL CTE plan left
f64 assignment params untyped and panicked).