[PR #5160] [MERGED] fix(adapter): inconsistent mongo ends_with query #5815

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

📋 Pull Request Information

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

Base: canaryHead: fix/mongo-inconsistent-endswith


📝 Commits (10+)

📊 Changes

7 files changed (+441 additions, -68 deletions)

View changed files

📝 packages/better-auth/src/adapters/adapter-factory/index.ts (+10 -5)
📝 packages/better-auth/src/adapters/create-test-suite.ts (+1 -2)
📝 packages/better-auth/src/adapters/mongodb-adapter/adapter.mongo-db.test.ts (+0 -1)
📝 packages/better-auth/src/adapters/mongodb-adapter/mongodb-adapter.ts (+28 -4)
📝 packages/better-auth/src/adapters/test-adapter.ts (+0 -6)
📝 packages/better-auth/src/adapters/tests/normal.ts (+401 -49)
📝 packages/better-auth/src/adapters/tests/number-id.ts (+1 -1)

📄 Description

Fixes inconsistent ends_with query in mongoDB.
Also removes all retrys with adapter tests, everything should one-shot work.

linear: https://linear.app/better-auth/issue/ENG-209/fix-mongo-inconsistent-regex-searches


Summary by cubic

Fixes inconsistent ends_with behavior in the MongoDB adapter and removes retry logic from adapter tests. Aligns starts_with behavior and adds focused tests for filtering and sorting.

  • Bug Fixes

    • Updated MongoDB ends_with to use ${value}$ matching.
    • Updated starts_with to use ^${value}
  • Refactors

    • Removed defaultRetryCount and all retry usage from adapter test helpers and suites.
    • Strengthened normal tests with ends_with cases, symbol-based contains, and a combined where + sort + limit + offset scenario.

🔄 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/5160 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 10/8/2025 **Status:** ✅ Merged **Merged:** 10/15/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/mongo-inconsistent-endswith` --- ### 📝 Commits (10+) - [`e46c8c1`](https://github.com/better-auth/better-auth/commit/e46c8c1abc0eefd8dd57891a4164ec88aaa18d08) fix(adapter): inconsistent mongo `ends_with` query - [`65629c0`](https://github.com/better-auth/better-auth/commit/65629c03b1eef5580b1e0e687f71142669c8a7e6) fix: remove mongo case insensativity - [`513dc68`](https://github.com/better-auth/better-auth/commit/513dc68b1e3cf2a1268a4236f7d08bbc4aaf8d82) fix: adapter tests would break drizzle mysql - [`7371044`](https://github.com/better-auth/better-auth/commit/7371044056f4a096d390ffaf765c1f7717bbc7c9) chore: cleanup - [`9845e06`](https://github.com/better-auth/better-auth/commit/9845e06ae07f33d3e3086811be54a721e7511f65) fix: prevent mongodb regex injection - [`a99c5bc`](https://github.com/better-auth/better-auth/commit/a99c5bcd800ad3ce9fc71f7eb15d264a37ab9105) Merge branch 'canary' into fix/mongo-inconsistent-endswith - [`f9d7ad1`](https://github.com/better-auth/better-auth/commit/f9d7ad172821567d4d45af4e7fc4df0a99050535) chore: lint - [`e44b93c`](https://github.com/better-auth/better-auth/commit/e44b93cfd92a575568186a77fb5c51d0e5c73fa4) Merge branch 'fix/mongo-inconsistent-endswith' of https://github.com/ping-maxwell/better-auth into fix/mongo-inconsistent-endswith - [`13b8791`](https://github.com/better-auth/better-auth/commit/13b8791a6508ea2fd713beb331d5ea3fd6888cf9) Merge branch 'canary' into fix/mongo-inconsistent-endswith - [`dc77311`](https://github.com/better-auth/better-auth/commit/dc77311d776b0e735ec4df5d5ac821db4dbb70aa) fix: DB consistency ### 📊 Changes **7 files changed** (+441 additions, -68 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/adapter-factory/index.ts` (+10 -5) 📝 `packages/better-auth/src/adapters/create-test-suite.ts` (+1 -2) 📝 `packages/better-auth/src/adapters/mongodb-adapter/adapter.mongo-db.test.ts` (+0 -1) 📝 `packages/better-auth/src/adapters/mongodb-adapter/mongodb-adapter.ts` (+28 -4) 📝 `packages/better-auth/src/adapters/test-adapter.ts` (+0 -6) 📝 `packages/better-auth/src/adapters/tests/normal.ts` (+401 -49) 📝 `packages/better-auth/src/adapters/tests/number-id.ts` (+1 -1) </details> ### 📄 Description Fixes inconsistent `ends_with` query in mongoDB. Also removes all `retry`s with adapter tests, everything should one-shot work. linear: https://linear.app/better-auth/issue/ENG-209/fix-mongo-inconsistent-regex-searches <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes inconsistent ends_with behavior in the MongoDB adapter and removes retry logic from adapter tests. Aligns starts_with behavior and adds focused tests for filtering and sorting. - **Bug Fixes** - Updated MongoDB ends_with to use `${value}$` matching. - Updated starts_with to use `^${value}` - **Refactors** - Removed defaultRetryCount and all retry usage from adapter test helpers and suites. - Strengthened normal tests with ends_with cases, symbol-based contains, and a combined where + sort + limit + offset scenario. <!-- 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:37:28 -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#5815