fix(prisma-adapter): lift eq AND conditions to root so update detects unique where field#7096
Merged
Bekacru merged 3 commits intobetter-auth:canaryfrom Jan 2, 2026
Conversation
|
@ping-maxwell is attempting to deploy a commit to the better-auth Team on Vercel. A member of the Team first needs to authorize it. |
update operations fail with non-unique fields
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts">
<violation number="1" location="packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts:466">
P2: Debug `console.log` statement should be removed before merging. This will log internal query details to the console on every update operation in production.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts
Outdated
Show resolved
Hide resolved
better-auth
@better-auth/cli
@better-auth/core
@better-auth/expo
@better-auth/oauth-provider
@better-auth/passkey
@better-auth/scim
@better-auth/sso
@better-auth/stripe
@better-auth/telemetry
commit: |
1 task
himself65
pushed a commit
that referenced
this pull request
Jan 10, 2026
… unique where field (#7096)
himself65
pushed a commit
that referenced
this pull request
Jan 10, 2026
… unique where field (#7096)
himself65
pushed a commit
that referenced
this pull request
Jan 10, 2026
… unique where field (#7096)
himself65
pushed a commit
that referenced
this pull request
Jan 10, 2026
… unique where field (#7096)
himself65
pushed a commit
that referenced
this pull request
Jan 10, 2026
… unique where field (#7096)
himself65
pushed a commit
that referenced
this pull request
Jan 12, 2026
… unique where field (#7096)
himself65
pushed a commit
that referenced
this pull request
Jan 12, 2026
… unique where field (#7096)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #5929
There are cases where we call
adapter.updateand even if we provide a unique field it will still fail saying we didn't.This happens because if the where clause of the update included two where conditions making it an
ANDoperation then Prisma will not detect that unique field within theANDarray as it requires all unique field to be defined at the root level of the where clause object.This PR simply extracts the AND clause that uses
eqoperations to be at the root level of the where obj underupdateactions.Summary by cubic
Fixes Prisma adapter update failures when a unique field is nested under AND. Simple equality filters are lifted to the root of the where clause so Prisma recognizes the unique field.
Written for commit 41af0c9. Summary will update on new commits.