Skip to content

fix(transactions): handle common irregular English plurals in pluralize()#136

Merged
RAprogramm merged 1 commit into
mainfrom
135
May 11, 2026
Merged

fix(transactions): handle common irregular English plurals in pluralize()#136
RAprogramm merged 1 commit into
mainfrom
135

Conversation

@RAprogramm
Copy link
Copy Markdown
Owner

Closes #135

Summary

`pluralize` only handled regular suffix rules, so irregular nouns came out grammatically wrong in transaction accessor names. Not a data-corruption bug — only generated method names were affected — but ten common English irregulars now match expectation.

Singular Was Now
child childs children
person persons people
mouse mouses mice
goose gooses geese
foot foots feet
tooth tooths teeth
man mans men
woman womans women
datum datums data
criterion criterions criteria

New helper `irregular_plural` checks a small fixed table first (case-insensitive on the singular, casing preserved on the plural). `pluralize` falls through to the existing regular logic on miss. Exact-word match only — `childcare → childcares` (not `childrencare`).

Tests

16 lib unit tests covering all ten irregulars, the case-insensitive lookup, the compound-word guard, and the four regular paths.

Version bump

Crate Old New
entity-derive-impl 0.6.4 0.6.5
entity-derive 0.8.5 0.8.6

`entity-core` is unchanged.

Test plan

  • `cargo test --all-features` — 567 lib + 9 streams + 45 core + 2 integration + trybuild pass.
  • `cargo clippy --all-targets --all-features -- -D warnings` — clean.
  • `cargo +nightly fmt --all -- --check` — clean.
  • CI + Codecov green before merge.

Out of scope

`#[entity(plural = "...")]` override for exotic Latin/Greek/loanword plurals. Open a follow-up if a real entity name needs it.

…uralize()

`pluralize` in `entity/transaction.rs` only handled regular suffix rules
(`+s`, `+es` after sibilants, consonant-y → -ies). Irregular nouns came
out grammatically wrong in the transaction accessor names:

  child     → childs       (was) → children    (now)
  person    → persons      (was) → people      (now)
  mouse     → mouses       (was) → mice        (now)
  goose     → gooses       (was) → geese       (now)
  foot      → foots        (was) → feet        (now)
  tooth     → tooths       (was) → teeth       (now)
  man       → mans         (was) → men         (now)
  woman     → womans       (was) → women       (now)
  datum     → datums       (was) → data        (now)
  criterion → criterions   (was) → criteria    (now)

Not a data-corruption bug — the irregular only appeared in generated
method names (`Transaction::with_<plural>()`, `ctx.<plural>()`) — but it
made `#[entity(transactions)]` on entities like `Child` or `Person` look
unpolished.

New helper `irregular_plural(word)` looks up a small fixed table of the
ten most common English irregulars (case-insensitive match on the
singular, original casing preserved on the plural). `pluralize` checks
it first and falls back to the existing regular-suffix logic on miss.
Exact-word match only — `childcare` stays `childcares`, not
`childrencare`.

Tests:

- 16 new lib unit tests in `entity::transaction::tests` covering all
  ten irregulars, the case-insensitive lookup, the compound-word guard,
  and the three regular paths (sibilants, consonant-y → -ies, vowel-y
  stays, default +s).

Bump (changed crates only):

- entity-derive-impl: 0.6.4 -> 0.6.5
- entity-derive:      0.8.5 -> 0.8.6

Out of scope: an explicit `#[entity(plural = "...")]` override for
exotic plurals beyond the ten irregulars. If a real need surfaces,
open a follow-up issue.

Closes #135
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@RAprogramm RAprogramm merged commit 6a2b783 into main May 11, 2026
17 checks passed
@RAprogramm RAprogramm deleted the 135 branch May 11, 2026 11:21
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.

fix(transactions): handle common irregular English plurals in pluralize()

1 participant