[PR #7786] fix: correct double pluralization of already-plural model names #33154

Open
opened 2026-04-17 23:49:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7786
Author: @bytaesu
Created: 2/4/2026
Status: 🔄 Open

Base: main ← Head: 2026-02-04/feat/add-pluralize


📝 Commits (3)

📊 Changes

8 files changed (+1368 additions, -33 deletions)

View changed files

📝 packages/cli/src/generators/drizzle.ts (+2 -1)
📝 packages/cli/src/generators/prisma.ts (+2 -1)
➕ packages/core/src/db/adapter/get-model-name.test.ts (+99 -0)
📝 packages/core/src/db/adapter/get-model-name.ts (+3 -2)
➕ packages/core/src/utils/pluralize.test.ts (+799 -0)
➕ packages/core/src/utils/pluralize.ts (+439 -0)
📝 packages/drizzle-adapter/src/drizzle-adapter.ts (+19 -27)
📝 packages/prisma-adapter/src/prisma-adapter.ts (+5 -2)

📄 Description

Note

usePlural + uncountable model names
DB migration needed
Impact: Kysely, Drizzle, Prisma

usePlural: true / Custom plural model names + usePlural: false
@better-auth/cli generate required for one-to-many joins (no DB changes)
Impact: Drizzle, Prisma

I'm thinking that even if it's not grammatically perfect just appending "s" might be safer for DB operations


Summary by cubic

Prevents double pluralization of already-plural model names across generators and adapters. Adds a pluralize utility and uses safePlural so relation keys and model names stay consistent when usePlural is enabled.

  • New Features

    • Added pluralize utils: plural, singular, isPlural, isSingular, safePlural.
    • Added comprehensive tests for pluralization and getModelName.
  • Bug Fixes

    • Use safePlural in Prisma/Drizzle CLI generators for many relation field names.
    • Use safePlural in Prisma/Drizzle adapters when building include/join keys and mapping results.
    • Update getModelName to use safePlural for default and custom model names.

Written for commit c2a5ea4829. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7786 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `2026-02-04/feat/add-pluralize` --- ### 📝 Commits (3) - [`d5578f1`](https://github.com/better-auth/better-auth/commit/d5578f1c15ce52f3495eb47dbd9dc2593d077962) feat: add pluralize utils - [`a5553a6`](https://github.com/better-auth/better-auth/commit/a5553a6a6396dea7adbbf9b47a39b4d2f48be4c0) chore: disable cspell - [`c2a5ea4`](https://github.com/better-auth/better-auth/commit/c2a5ea48294c8b96fcc11a78f36af57990624e4f) feat: use safePlural ### 📊 Changes **8 files changed** (+1368 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/drizzle.ts` (+2 -1) 📝 `packages/cli/src/generators/prisma.ts` (+2 -1) ➕ `packages/core/src/db/adapter/get-model-name.test.ts` (+99 -0) 📝 `packages/core/src/db/adapter/get-model-name.ts` (+3 -2) ➕ `packages/core/src/utils/pluralize.test.ts` (+799 -0) ➕ `packages/core/src/utils/pluralize.ts` (+439 -0) 📝 `packages/drizzle-adapter/src/drizzle-adapter.ts` (+19 -27) 📝 `packages/prisma-adapter/src/prisma-adapter.ts` (+5 -2) </details> ### 📄 Description > [!NOTE] > > 1. > usePlural + uncountable model names > DB migration needed > Impact: Kysely, Drizzle, Prisma > > 2. > usePlural: true / Custom plural model names + usePlural: false > @better-auth/cli generate required for one-to-many joins (no DB changes) > Impact: Drizzle, Prisma I'm thinking that even if it's not grammatically perfect just appending "s" might be safer for DB operations - Closes https://github.com/better-auth/better-auth/issues/7773 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevents double pluralization of already-plural model names across generators and adapters. Adds a pluralize utility and uses safePlural so relation keys and model names stay consistent when usePlural is enabled. - **New Features** - Added pluralize utils: plural, singular, isPlural, isSingular, safePlural. - Added comprehensive tests for pluralization and getModelName. - **Bug Fixes** - Use safePlural in Prisma/Drizzle CLI generators for many relation field names. - Use safePlural in Prisma/Drizzle adapters when building include/join keys and mapping results. - Update getModelName to use safePlural for default and custom model names. <sup>Written for commit c2a5ea48294c8b96fcc11a78f36af57990624e4f. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 23:49:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#33154