Skip to content

#219 feat: chainable setters on update DTOs#264

Merged
RAprogramm merged 1 commit into
mainfrom
219
Jul 26, 2026
Merged

#219 feat: chainable setters on update DTOs#264
RAprogramm merged 1 commit into
mainfrom
219

Conversation

@RAprogramm

Copy link
Copy Markdown
Owner

Closes #219

A patch built from a struct literal has to spell the wrapping out — Some(value) for a plain column, Some(Some(value)) for a nullable one, Some(None) to write NULL. Correct, and opaque at the call site.

Update DTOs now carry setters that say it in the caller's words:

Generated For
set_{field}(value) every updatable column
clear_{field}() nullable columns — asks for NULL, which is not the same as leaving the field alone
expecting_version(v) entities declaring #[version]
let patch = UpdateParcelRequest::default()
    .set_status("accepted".into())
    .set_courier_id(courier)
    .expecting_version(3);

Purely additive: struct-literal construction is untouched, and the serialized shape does not change.

Covered by a compile-pass case for the produced values and a live-Postgres case proving the built patch reaches the row — including that clear_ writes NULL while an untouched field keeps its stored value. README and the attribute page in all five wiki languages document it.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/entity-derive-impl/src/entity/dto.rs 96.96% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@RAprogramm
RAprogramm merged commit c9d4f0e into main Jul 26, 2026
22 checks passed
@RAprogramm
RAprogramm deleted the 219 branch July 26, 2026 11:27
@RAprogramm RAprogramm mentioned this pull request Jul 26, 2026
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(dto): builder helpers for double-Option update DTOs

1 participant