Skip to content

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

@RAprogramm

Description

@RAprogramm

Problem

`crates/entity-derive-impl/src/entity/transaction.rs::pluralize` only handles the regular English suffix rules: `+s`, `+es` after `s/x/z/ch/sh`, and consonant-y → `ies`. Irregular nouns end up with grammatical noise:

Singular Generated Correct
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

These only surface in user-facing method names (`with_()` on `Transaction`, `ctx.()` on `TransactionContext`) so it's not a data-corruption bug — but it's the kind of detail that makes `#[entity(transactions)]` look unprofessional on entities with common irregular names.

Fix

In `pluralize`, check a small built-in map of irregulars first and fall back to the existing regular-suffix logic if not matched. Match the lowercase form so `Child` / `CHILD` / `child` all hit `children`.

Scope

Just the 10 most common English irregulars listed above. We don't try to be a full inflection library — anything past these is unusual enough that the user should rename their entity. (If a real need surfaces later, a follow-up could add an explicit `#[entity(plural = "people")]` override, but not in this PR.)

Tests

Unit tests in the existing test module for each irregular plus a few control cases that must keep using the regular rules (`user → users`, `box → boxes`, `category → categories`).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions