Skip to content

216#223

Merged
RAprogramm merged 1 commit into
mainfrom
216
Jul 5, 2026
Merged

216#223
RAprogramm merged 1 commit into
mainfrom
216

Conversation

@RAprogramm

Copy link
Copy Markdown
Owner

Closes #216.

Repeatable #[transition(source | source -> target, sets(col, ...))] declarations generate locking state-machine methods on the transaction adapter:

  • transition_to_{target}(id, sets...)SELECT ... FOR UPDATE, source-status verification, one UPDATE patching status + the sets(...) columns, RETURNING *
  • Ok(None) = row absent; disallowed transition = typed entity_core::TransitionError (new type; consumer error must implement From<TransitionError> — map to 409)
  • sets parameters unwrap Option columns to their inner type
  • Compile-time validation: requires transactions, an updatable status field, a custom error type; sets columns must be #[field(update)]

Validated against a real consumer: four production transitions (accept with courier/ticket assignment, pickup, deliver, two-source cancel) replaced hand-written lock-check-update blocks; the consumer's full integration suite passes against live Postgres.

Wiki (Transactions-en) documents the attribute.

@RAprogramm RAprogramm merged commit d82cd75 into main Jul 5, 2026
8 checks passed
@RAprogramm RAprogramm deleted the 216 branch July 5, 2026 04:35
@RAprogramm RAprogramm mentioned this pull request Jul 5, 2026
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.74074% with 20 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...derive-impl/src/entity/parse/entity/constructor.rs 58.97% 16 Missing ⚠️
crates/entity-core/src/lib.rs 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sql): declarative state machine on status enums (#[transition])

1 participant