Skip to content

feat: Deprecation - return MongoDB explain results as an array via databaseOptions.explainResultsAsArray - #10552

Open
dblythy wants to merge 2 commits into
parse-community:alphafrom
dblythy:fix/mongo-explain-results-as-array
Open

feat: Deprecation - return MongoDB explain results as an array via databaseOptions.explainResultsAsArray#10552
dblythy wants to merge 2 commits into
parse-community:alphafrom
dblythy:fix/mongo-explain-results-as-array

Conversation

@dblythy

@dblythy dblythy commented Jul 5, 2026

Copy link
Copy Markdown
Member

Closes #7442

This revives #7440 (closed back in 2023 as a breaking change) but phases it in via the deprecation policy rather than breaking outright.

MongoDB's explain on a find returns a single object, whereas find and the Postgres adapter always return an array - which breaks strongly-typed SDKs (Swift etc) that decode results as an array. This normalises Mongo's explain result to an array so it's consistent.

Since that's a breaking change it's opt-in for now behind a new databaseOptions.explainResultsAsArray (default false = current object behaviour), plus a deprecation warning that the default flips to true in the next major (DEPPS25, id is just the next free one - happy to renumber). Postgres already returns an array so the Array.isArray guard leaves it untouched, no double-wrap.

Existing explain tests stay green untouched (proof it's non-breaking today); new opt-in test added. Verified on both Mongo and Postgres via specs and a live server.

Summary by CodeRabbit

  • New Features

    • Added a database option (explainResultsAsArray) to return MongoDB Query.explain() results as an array, aligning output with other adapters.
    • Supports configuration and an environment variable for the option.
  • Bug Fixes

    • When enabled, MongoDB explain output is normalized to the expected array shape; legacy single-object behavior remains the default.
  • Deprecations

    • Added a deprecation plan for this option, including a future default change and a breaking change in a later major release.
  • Documentation

    • Updated option docs and the deprecation timeline.

@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e7761495-f3c0-498b-b983-8773007f15d3

📥 Commits

Reviewing files that changed from the base of the PR and between 0712456 and 4f8c0d7.

📒 Files selected for processing (4)
  • spec/ParseQuery.spec.js
  • src/Options/Definitions.js
  • src/Options/docs.js
  • src/Options/index.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/Options/Definitions.js
  • src/Options/docs.js
  • spec/ParseQuery.spec.js

📝 Walkthrough

Walkthrough

The change adds databaseOptions.explainResultsAsArray, defaulting to legacy single-object MongoDB explain results. When enabled, DatabaseController.find returns an array, validates the option, documents it, filters it from MongoDB client options, and adds coverage and deprecation metadata.

Changes

MongoDB explain result shape

Layer / File(s) Summary
Option contract and lifecycle
src/Options/..., src/Config.js, src/defaults.js, src/Deprecator/..., DEPRECATIONS.md
Defines and documents the boolean option, validates its value, defaults it to false, excludes it from MongoDB client options, and records its planned default change.
Explain result normalization
src/Controllers/DatabaseController.js, spec/ParseQuery.spec.js
Wraps MongoDB explain objects in an array when enabled and tests both array and legacy object response shapes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ParseQueryExplain
  participant DatabaseControllerFind
  participant MongoAdapter
  ParseQueryExplain->>DatabaseControllerFind: request explain query
  DatabaseControllerFind->>MongoAdapter: execute find with explain
  MongoAdapter-->>DatabaseControllerFind: return explain object
  DatabaseControllerFind-->>ParseQueryExplain: return array when option is enabled
Loading

Possibly related PRs

Suggested reviewers: mtrezza


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 inconclusive)

Check name Status Explanation Resolution
Description check ❌ Error The description lacks the required template sections for Issue, Approach, and Tasks. Rewrite the PR description using the repository template and include Issue, Approach, and Tasks sections with the completed checklist.
Engage In Review Feedback ❓ Inconclusive Repo shows one feature commit and no review-thread evidence; I can’t verify that feedback was discussed before resolution. Provide PR review comments or thread history showing the feedback was discussed, or a follow-up commit/retraction that resolves it.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the PR’s main change and uses the required feat: prefix.
Linked Issues check ✅ Passed The changes implement #7442 by normalizing MongoDB explain results to an array while preserving legacy behavior via the new option.
Out of Scope Changes check ✅ Passed The edits stay aligned with the issue: option definition, validation, deprecation docs, behavior change, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Security Check ✅ Passed Changes are defensive (error redaction, context isolation, geo-index handling) and I found no new eval/injection/auth-bypass/prototype-pollution patterns.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.3)
src/Options/index.js

File contains syntax errors that prevent linting: Line 18: Expected a type but instead found '?'.; Line 18: Expected a property, or a signature but instead found ';'.; Line 21: Expected a statement but instead found '?'.; Line 24: Expected a statement but instead found '?'.; Line 27: Expected a statement but instead found '?'.; Line 30: Expected a statement but instead found '?'.; Line 32: Expected a statement but instead found '?'.; Line 34: Expected a statement but instead found '?'.; Line 35: Expected a statement but instead found '}'.; Line 37: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 38: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 39: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 40: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Li

... [truncated 16812 characters] ...

found '?'.; Line 915: Expected a statement but instead found '?'.; Line 917: Expected a statement but instead found '?'.; Line 918: Expected a statement but instead found '}'.; Line 932: Expected a type but instead found '?'.; Line 932: Expected a property, or a signature but instead found ';'.; Line 933: Expected a statement but instead found '}'.; Line 939: Expected a type but instead found '?'.; Line 939: Expected a property, or a signature but instead found ';'.; Line 943: Expected a statement but instead found '?'.; Line 947: Expected a statement but instead found '?'.; Line 951: Expected a statement but instead found '?'.; Line 955: Expected a statement but instead found '?'.; Line 959: Expected a statement but instead found '?'.; Line 960: Expected a statement but instead found '}'.

🔧 ast-grep (0.44.1)
spec/ParseQuery.spec.js

ast-grep timed out on this file


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.78%. Comparing base (64d58ff) to head (4f8c0d7).
⚠️ Report is 1 commits behind head on alpha.

Files with missing lines Patch % Lines
src/Config.js 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            alpha   #10552      +/-   ##
==========================================
- Coverage   93.78%   93.78%   -0.01%     
==========================================
  Files         192      192              
  Lines       16832    16837       +5     
  Branches      248      248              
==========================================
+ Hits        15786    15790       +4     
- Misses       1025     1026       +1     
  Partials       21       21              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dblythy

dblythy commented Jul 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mongo explain results incorrectly returning an object instead of an array of objects

2 participants