[PR #5173] [MERGED] docs: clarify generateId behavior and mixed ID types #5824

Closed
opened 2026-03-13 12:37:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5173
Author: @ahmed-abdat
Created: 10/8/2025
Status: Merged
Merged: 10/15/2025
Merged by: @ping-maxwell

Base: canaryHead: docs/clarify-generateid-behavior


📝 Commits (10+)

  • d443d48 docs: clarify generateId behavior and mixed ID type handling
  • 965c890 docs: remove unnecessary type assertions from generateId examples
  • 1f46410 docs: fix incorrect returned property documentation
  • 631a56c Merge branch 'canary' into docs/clarify-generateid-behavior
  • e3b04c0 Merge branch 'canary' into docs/clarify-generateid-behavior
  • d26dda8 docs: remove unimplemented additional field properties and update ID generation guidance
  • 5968d15 chore: merge latest from upstream canary
  • 17005e5 Merge branch 'canary' into docs/clarify-generateid-behavior
  • 54e71d4 Merge branch 'canary' into docs/clarify-generateid-behavior
  • f188056 docs: make useNumberId the recommended approach for auto-increment IDs

📊 Changes

1 file changed (+85 additions, -18 deletions)

View changed files

📝 docs/content/docs/concepts/database.mdx (+85 -18)

📄 Description

Clarifies the documentation for generateId configuration and mixed ID type handling, addressing confusion around when to use generateId: false vs returning false/undefined from a function.

Closes #5081


Summary by cubic

Clarifies how generateId works and how to mix ID types safely, with examples and warnings. Documents additionalFields.returned and fieldName, and database hooks property naming, closing #5081.

  • Migration
    • Set generateId: false to let the database generate IDs for all tables.
    • For mixed ID types, use a generateId function; return false/undefined for DB-generated models and generate UUIDs for others. Do not use useNumberId.
    • If a field uses a different fieldName than its property, set returned: true to include it in SELECT queries.
    • In databaseHooks, use JavaScript property names (e.g., firstName), not database column names.

🔄 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/5173 **Author:** [@ahmed-abdat](https://github.com/ahmed-abdat) **Created:** 10/8/2025 **Status:** ✅ Merged **Merged:** 10/15/2025 **Merged by:** [@ping-maxwell](https://github.com/ping-maxwell) **Base:** `canary` ← **Head:** `docs/clarify-generateid-behavior` --- ### 📝 Commits (10+) - [`d443d48`](https://github.com/better-auth/better-auth/commit/d443d487b1f4555e695e0384d90fffd2dbfe812c) docs: clarify generateId behavior and mixed ID type handling - [`965c890`](https://github.com/better-auth/better-auth/commit/965c89029930e0de109be699c79d36e5684202ff) docs: remove unnecessary type assertions from generateId examples - [`1f46410`](https://github.com/better-auth/better-auth/commit/1f46410663788096c17a8dfca228e6115bbbd038) docs: fix incorrect returned property documentation - [`631a56c`](https://github.com/better-auth/better-auth/commit/631a56c4b75f006b74b8038f738384b3d1a0c96c) Merge branch 'canary' into docs/clarify-generateid-behavior - [`e3b04c0`](https://github.com/better-auth/better-auth/commit/e3b04c07ddaed8c8d6398d77d2693b09e60a7869) Merge branch 'canary' into docs/clarify-generateid-behavior - [`d26dda8`](https://github.com/better-auth/better-auth/commit/d26dda89f7537236f3ea844f8c903c2cededec4a) docs: remove unimplemented additional field properties and update ID generation guidance - [`5968d15`](https://github.com/better-auth/better-auth/commit/5968d151ba9c804e02cc15942caba092e9a12c90) chore: merge latest from upstream canary - [`17005e5`](https://github.com/better-auth/better-auth/commit/17005e582ea14dfa9d15a6b9de8c9eb79cb2d1a3) Merge branch 'canary' into docs/clarify-generateid-behavior - [`54e71d4`](https://github.com/better-auth/better-auth/commit/54e71d49838fdfb42cce31ceefeca0c555a8a507) Merge branch 'canary' into docs/clarify-generateid-behavior - [`f188056`](https://github.com/better-auth/better-auth/commit/f18805644b7ffa9287031723677152e2593e10a9) docs: make useNumberId the recommended approach for auto-increment IDs ### 📊 Changes **1 file changed** (+85 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/database.mdx` (+85 -18) </details> ### 📄 Description Clarifies the documentation for `generateId` configuration and mixed ID type handling, addressing confusion around when to use `generateId: false` vs returning `false`/`undefined` from a function. Closes #5081 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Clarifies how generateId works and how to mix ID types safely, with examples and warnings. Documents additionalFields.returned and fieldName, and database hooks property naming, closing #5081. - **Migration** - Set generateId: false to let the database generate IDs for all tables. - For mixed ID types, use a generateId function; return false/undefined for DB-generated models and generate UUIDs for others. Do not use useNumberId. - If a field uses a different fieldName than its property, set returned: true to include it in SELECT queries. - In databaseHooks, use JavaScript property names (e.g., firstName), not database column names. <!-- 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-03-13 12:37:45 -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#5824