[PR #5686] fix(adapters): mongodb id issue #14406

Closed
opened 2026-04-13 09:27:32 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5686

State: closed
Merged: Yes


This PR adds serializeID to MongoDB actions: gt, gte, lt, lte and ne to ensure the id is converted to ObjectId for future actions.

This PR fixes #5143


Summary by cubic

Fixes MongoDB id comparisons by converting values to ObjectId for gt/gte/lt/lte/ne, and improves Prisma where handling for nulls and in/not_in. Filters using id or _id now return correct results, including in Admin listUsers.

  • Bug Fixes
    • Use serializeID for gt/gte/lt/lte/ne when comparing id/_id (skips null/undefined).
    • Prisma: ignore ne with null, filter nulls in in/not_in arrays, and handle empty arrays safely.
    • Add tests for adapter findMany (id/_id ne, ne null, in with null) and Admin listUsers with id/_id ne.

Written for commit 3cd8c5b. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5686 **State:** closed **Merged:** Yes --- This PR adds `serializeID` to MongoDB actions: `gt`, `gte`, `lt`, `lte` and `ne` to ensure the id is converted to ObjectId for future actions. This PR fixes #5143 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes MongoDB id comparisons by converting values to ObjectId for gt/gte/lt/lte/ne, and improves Prisma where handling for nulls and in/not_in. Filters using id or _id now return correct results, including in Admin listUsers. - **Bug Fixes** - Use serializeID for gt/gte/lt/lte/ne when comparing id/_id (skips null/undefined). - Prisma: ignore ne with null, filter nulls in in/not_in arrays, and handle empty arrays safely. - Add tests for adapter findMany (id/_id ne, ne null, in with null) and Admin listUsers with id/_id ne. <sup>Written for commit 3cd8c5b. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:27:32 -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#14406