[PR #8314] [MERGED] fix(prisma-adapter): use deleteMany when deleting by non-unique field #24791

Closed
opened 2026-04-15 22:33:43 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8314
Author: @himself65
Created: 3/3/2026
Status: Merged
Merged: 3/3/2026
Merged by: @himself65

Base: canaryHead: fix/prisma-delete-non-unique-field


📝 Commits (1)

  • 7a6039f fix(prisma-adapter): use deleteMany when deleting by non-unique field

📊 Changes

2 files changed (+35 additions, -1 deletions)

View changed files

📝 e2e/adapter/test/adapter-factory/basic.ts (+21 -1)
📝 packages/prisma-adapter/src/prisma-adapter.ts (+14 -0)

📄 Description

Summary

  • Fixes Prisma adapter's delete() method to fall back to deleteMany() when the where clause doesn't contain an id field, since Prisma's delete() requires a WhereUniqueInput (unique/primary key)
  • This fixes the deleteVerificationByIdentifier flow where identifier is not a unique field on the verification table
  • Adds e2e adapter test to verify deletion by non-unique field works across all adapters

Closes #8313

Test plan

  • Added "delete - should delete by non-unique field" test in e2e/adapter/test/adapter-factory/basic.ts
  • Verified all memory adapter tests pass (412 passed, 1 skipped)
  • Verified lint and format checks pass

🔄 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/8314 **Author:** [@himself65](https://github.com/himself65) **Created:** 3/3/2026 **Status:** ✅ Merged **Merged:** 3/3/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/prisma-delete-non-unique-field` --- ### 📝 Commits (1) - [`7a6039f`](https://github.com/better-auth/better-auth/commit/7a6039fb13eb92b598ec8b4665fd56414dca0f45) fix(prisma-adapter): use deleteMany when deleting by non-unique field ### 📊 Changes **2 files changed** (+35 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `e2e/adapter/test/adapter-factory/basic.ts` (+21 -1) 📝 `packages/prisma-adapter/src/prisma-adapter.ts` (+14 -0) </details> ### 📄 Description ## Summary - Fixes Prisma adapter's `delete()` method to fall back to `deleteMany()` when the where clause doesn't contain an `id` field, since Prisma's `delete()` requires a `WhereUniqueInput` (unique/primary key) - This fixes the `deleteVerificationByIdentifier` flow where `identifier` is not a unique field on the verification table - Adds e2e adapter test to verify deletion by non-unique field works across all adapters Closes #8313 ## Test plan - [x] Added "delete - should delete by non-unique field" test in `e2e/adapter/test/adapter-factory/basic.ts` - [x] Verified all memory adapter tests pass (412 passed, 1 skipped) - [x] Verified lint and format checks pass --- <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-15 22:33:43 -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#24791