[PR #5904] [MERGED] feat(prisma): enhance JSON default value handling for arrays and objects in schema generation #6310

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5904
Author: @rovertrack
Created: 11/11/2025
Status: Merged
Merged: 11/11/2025
Merged by: @himself65

Base: canaryHead: fix/jsondefaults


📝 Commits (6)

  • 482afd3 feat(prisma): Enhance JSON default value handling for arrays and objects in schema generation
  • cb93584 Update packages/core/src/db/type.ts
  • 2946e99 Update packages/cli/src/generators/prisma.ts
  • 51e10b9 Update packages/cli/src/generators/prisma.ts
  • bfac068 Update packages/cli/src/generators/prisma.ts
  • b624385 Formatting "Lint error"

📊 Changes

3 files changed (+106 additions, -2 deletions)

View changed files

📝 packages/cli/src/generators/prisma.ts (+65 -1)
📝 packages/cli/test/generate.test.ts (+39 -0)
📝 packages/core/src/db/type.ts (+2 -1)

📄 Description

solves #5900

Added objects and arrays compatibility for default JSON values with test cases

The default string value is not sorted for mysql ,but will be soon be done with the #5866 PR


Summary by cubic

Adds support for JSON default values for arrays and objects in Prisma schema generation. This outputs correct @default strings with proper escaping and handles empty arrays and objects.

  • New Features
    • JSON defaults for arrays and objects are serialized and escaped in @default.
    • Empty defaults map to default([]) and default("{}").
    • Array defaults supported for string[] and number[] fields.
    • Expanded DBPrimitive to include objects and arrays; added tests for these cases.

Written for commit bfac068875. Summary will update automatically 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/5904 **Author:** [@rovertrack](https://github.com/rovertrack) **Created:** 11/11/2025 **Status:** ✅ Merged **Merged:** 11/11/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/jsondefaults` --- ### 📝 Commits (6) - [`482afd3`](https://github.com/better-auth/better-auth/commit/482afd3f6cac1607b1866cb9f2b8b7921ac439be) feat(prisma): Enhance JSON default value handling for arrays and objects in schema generation - [`cb93584`](https://github.com/better-auth/better-auth/commit/cb935844ca472b3e6088c56ec7599a304378086b) Update packages/core/src/db/type.ts - [`2946e99`](https://github.com/better-auth/better-auth/commit/2946e9904cddf19b3784325f1ba331ec2799fc2c) Update packages/cli/src/generators/prisma.ts - [`51e10b9`](https://github.com/better-auth/better-auth/commit/51e10b9a653f85ee2e109c3155766c5d5ddb8035) Update packages/cli/src/generators/prisma.ts - [`bfac068`](https://github.com/better-auth/better-auth/commit/bfac068875eb8bd1fa7d9f87158a21699de8e518) Update packages/cli/src/generators/prisma.ts - [`b624385`](https://github.com/better-auth/better-auth/commit/b6243852ce74a9be26ad217b2da788e7d99158a5) Formatting "Lint error" ### 📊 Changes **3 files changed** (+106 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/prisma.ts` (+65 -1) 📝 `packages/cli/test/generate.test.ts` (+39 -0) 📝 `packages/core/src/db/type.ts` (+2 -1) </details> ### 📄 Description **solves #5900** ### Added objects and arrays compatibility for default JSON values with test cases The default string value is not sorted for **mysql** ,but will be soon be done with the #5866 PR <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds support for JSON default values for arrays and objects in Prisma schema generation. This outputs correct @default strings with proper escaping and handles empty arrays and objects. - **New Features** - JSON defaults for arrays and objects are serialized and escaped in @default. - Empty defaults map to default([]) and default("{}"). - Array defaults supported for string[] and number[] fields. - Expanded DBPrimitive to include objects and arrays; added tests for these cases. <sup>Written for commit bfac068875eb8bd1fa7d9f87158a21699de8e518. Summary will update automatically 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-03-13 12:54:21 -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#6310