[PR #6601] [MERGED] fix(prisma): array field types incorrectly inserting #6773

Closed
opened 2026-03-13 13:11:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6601
Author: @ping-maxwell
Created: 12/8/2025
Status: Merged
Merged: 12/8/2025
Merged by: @Bekacru

Base: canaryHead: fix/prisma-array-field-types


📝 Commits (10+)

📊 Changes

10 files changed (+158 additions, -25 deletions)

View changed files

📝 packages/better-auth/src/adapters/drizzle-adapter/drizzle-adapter.ts (+5 -1)
📝 packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts (+5 -1)
📝 packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts (+4 -0)
📝 packages/better-auth/src/adapters/tests/basic.ts (+85 -0)
📝 packages/better-auth/src/context/__snapshots__/create-context.test.ts.snap (+1 -0)
📝 packages/better-auth/src/db/get-migration.ts (+23 -10)
📝 packages/cli/src/generators/drizzle.ts (+6 -8)
📝 packages/cli/src/generators/prisma.ts (+17 -3)
📝 packages/core/src/db/adapter/factory.ts (+4 -2)
📝 packages/core/src/db/adapter/index.ts (+8 -0)

📄 Description

closes https://github.com/better-auth/better-auth/issues/6552

Fixes array field handling (string[] and number[]) across adapters and schema generation. Arrays now persist correctly: SQLite as strings, PostgreSQL/MongoDB as native arrays, MySQL as JSON, MSSQL as varchar.

  • Bug Fixes
    • Added supportsArrays to adapter config; enabled in prismaAdapter (PostgreSQL, MongoDB) and drizzleAdapter (PostgreSQL); disabled in kyselyAdapter (stringify/parse arrays).
    • Use supportsArrays to stringify on write and parse on read when arrays aren’t supported.
    • Prisma CLI: map string[]/number[] and json to String for SQLite/MySQL; keep native arrays/json for PostgreSQL/MongoDB.
    • Drizzle CLI: for SQLite and MySQL, use json mode for string[]/number[] and json fields; keep arrays for PostgreSQL.
    • Migrations: map arrays to jsonb (PostgreSQL), json (MySQL), varchar(8000) (MSSQL), text (SQLite).
    • Added tests for creating and fetching models with array and json fields.

🔄 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/6601 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 12/8/2025 **Status:** ✅ Merged **Merged:** 12/8/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/prisma-array-field-types` --- ### 📝 Commits (10+) - [`ff8927f`](https://github.com/better-auth/better-auth/commit/ff8927f89724c0881e3b7a971a392d4a0f0afcb3) fix(prisma): Array field types incorrectly inserting - [`ef3324c`](https://github.com/better-auth/better-auth/commit/ef3324c2555548f834ad7cebdc24e39e7407504e) Update packages/cli/src/generators/prisma.ts - [`1ecf7a5`](https://github.com/better-auth/better-auth/commit/1ecf7a530885075a79bc4cd396c64a802ab0e90a) Merge branch 'canary' into fix/prisma-array-field-types - [`01defb2`](https://github.com/better-auth/better-auth/commit/01defb2342555639508ab5d7582e053fd839b9c1) chore: lint - [`b0a6b3e`](https://github.com/better-auth/better-auth/commit/b0a6b3e3c7fd742cb0dc12d1828f570f6a530d7e) fix: kysely mysql - [`15e8e7d`](https://github.com/better-auth/better-auth/commit/15e8e7d8367f5e6dbb74f0f8a55526386a871a74) chore: cleanup - [`cd2896c`](https://github.com/better-auth/better-auth/commit/cd2896cecc3d38748834606febe9391e2d9766c0) fix: drizzle sqlite - [`0cd1fbe`](https://github.com/better-auth/better-auth/commit/0cd1fbe1b649fb7b7a8c82896dbf8068e41a6231) fix: kysely.pg - [`0aa628c`](https://github.com/better-auth/better-auth/commit/0aa628cf093abd678e9ad0f2225417c96c6e31cb) fix: kysely.mssql - [`da49f87`](https://github.com/better-auth/better-auth/commit/da49f875fe41caffbfa006d98cac20ce7e64ea1d) fix: drizzle.pg ### 📊 Changes **10 files changed** (+158 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/drizzle-adapter/drizzle-adapter.ts` (+5 -1) 📝 `packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts` (+5 -1) 📝 `packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts` (+4 -0) 📝 `packages/better-auth/src/adapters/tests/basic.ts` (+85 -0) 📝 `packages/better-auth/src/context/__snapshots__/create-context.test.ts.snap` (+1 -0) 📝 `packages/better-auth/src/db/get-migration.ts` (+23 -10) 📝 `packages/cli/src/generators/drizzle.ts` (+6 -8) 📝 `packages/cli/src/generators/prisma.ts` (+17 -3) 📝 `packages/core/src/db/adapter/factory.ts` (+4 -2) 📝 `packages/core/src/db/adapter/index.ts` (+8 -0) </details> ### 📄 Description closes https://github.com/better-auth/better-auth/issues/6552 Fixes array field handling (string[] and number[]) across adapters and schema generation. Arrays now persist correctly: SQLite as strings, PostgreSQL/MongoDB as native arrays, MySQL as JSON, MSSQL as varchar. - **Bug Fixes** - Added supportsArrays to adapter config; enabled in prismaAdapter (PostgreSQL, MongoDB) and drizzleAdapter (PostgreSQL); disabled in kyselyAdapter (stringify/parse arrays). - Use supportsArrays to stringify on write and parse on read when arrays aren’t supported. - Prisma CLI: map string[]/number[] and json to String for SQLite/MySQL; keep native arrays/json for PostgreSQL/MongoDB. - Drizzle CLI: for SQLite and MySQL, use json mode for string[]/number[] and json fields; keep arrays for PostgreSQL. - Migrations: map arrays to jsonb (PostgreSQL), json (MySQL), varchar(8000) (MSSQL), text (SQLite). - Added tests for creating and fetching models with array and json fields. --- <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 13:11:17 -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#6773