Skip to content

fix: Parse.Query.containedIn and matchesQuery do not work with nested objects #9738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: alpha
Choose a base branch
from

Conversation

RahulLanjewar93
Copy link
Contributor

@RahulLanjewar93 RahulLanjewar93 commented Apr 29, 2025

Pull Request

Issue

#7414

Closes: #7414

Approach

Previously nested objects were converted to Child$ObjectID format before making a query to mongodb. Which was incorrect since nested objects are stored in their object format. Current change handles this edge case. Originally even nested objects should have been stored in Child$ObjectID format. But this is a fix we can provide for now.

Tasks

  • Add tests

Summary by CodeRabbit

  • Tests

    • Added new test cases to verify correct query behavior on nested objects containing pointers when using various constraints.
  • Refactor

    • Improved handling of nested keys and array fields in query constraint transformation to ensure accurate processing and clearer variable naming.

Copy link

The branch release can only be set as base branch by members of @parse-community/core-maintainers.

Pull requests are usually opened against the default branch alpha, which is the working branch. Different repositories may have base branches with different names. If you are sure you need to open this pull request against a different branch, please ask someone from the team mentioned above.

@parse-github-assistant parse-github-assistant bot changed the base branch from release to alpha April 29, 2025 13:30
Copy link

parse-github-assistant bot commented Apr 29, 2025

🚀 Thanks for opening this pull request!

Copy link

coderabbitai bot commented Apr 29, 2025

📝 Walkthrough

"""

Walkthrough

Three new test cases were added to the MongoStorageAdapter test suite, specifically under MongoDB-related tests. These tests focus on verifying the correct behavior of Parse queries involving nested objects containing pointer fields. The tests cover scenarios using the equalTo, containedIn, and matchesQuery query constraints on nested pointer fields. Each test involves creating and saving a Child object, embedding it as a pointer within a nested structure in a Parent object, saving the parent, and then querying the parent class to ensure the correct object is returned.

Additionally, the transformConstraint function in the MongoDB storage adapter was updated to accept an additional key parameter. This change improves handling of nested keys and array fields by selecting the appropriate transformation method and clarifies variable naming within the constraint processing loop. The caller function was updated accordingly to pass the new parameter.

Changes

File(s) Change Summary
spec/MongoStorageAdapter.spec.js Added three tests for querying nested pointer fields using equalTo, containedIn, and matchesQuery.
src/Adapters/Storage/Mongo/MongoTransform.js Updated transformConstraint to accept an additional key parameter; improved handling of nested keys and arrays; renamed variables inside the constraint loop for clarity; updated caller to pass new parameter.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner
    participant MongoDB
    participant ParseServer

    TestRunner->>ParseServer: Create and save Child object
    ParseServer->>MongoDB: Insert Child
    MongoDB-->>ParseServer: Ack

    TestRunner->>ParseServer: Create Parent object with nested Child pointer and save
    ParseServer->>MongoDB: Insert Parent (with nested pointer)
    MongoDB-->>ParseServer: Ack

    TestRunner->>ParseServer: Query Parent with constraint on nested pointer
    ParseServer->>MongoDB: Query Parent (with nested pointer constraint)
    MongoDB-->>ParseServer: Return matching Parent
    ParseServer-->>TestRunner: Return query results
Loading

Assessment against linked issues

Objective Addressed Explanation
Support deeply nested pointers in 'containedIn' queries (#7414)
Verify that 'containedIn' queries on nested pointer fields return expected results (#7414)
Ensure query transformations correctly handle nested keys and arrays (#7414)
"""

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec45ba0 and 649507d.

📒 Files selected for processing (1)
  • spec/MongoStorageAdapter.spec.js (1 hunks)
🧰 Additional context used
🪛 ESLint
spec/MongoStorageAdapter.spec.js

[error] 398-398: 'it' is not defined.

(no-undef)


[error] 417-417: 'expect' is not defined.

(no-undef)


[error] 420-420: 'it' is not defined.

(no-undef)


[error] 439-439: 'expect' is not defined.

(no-undef)


[error] 442-442: 'it' is not defined.

(no-undef)


[error] 461-461: 'expect' is not defined.

(no-undef)

🔇 Additional comments (4)
spec/MongoStorageAdapter.spec.js (4)

393-397: Clear and helpful comment that explains the issue being fixed.

This comment clearly documents the purpose of the tests: to verify that equalTo, containedIn, and matchesQuery all work properly with nested objects containing pointers. Good practice to include context.


398-418: Test confirms that equalTo works properly with nested pointers.

This test correctly validates that querying with equalTo on a nested pointer field returns the expected Parent object. The test creates the necessary object structure with a nested pointer and verifies the constraint works as expected.

🧰 Tools
🪛 ESLint

[error] 398-398: 'it' is not defined.

(no-undef)


[error] 417-417: 'expect' is not defined.

(no-undef)


420-440: Test confirms that containedIn works properly with nested pointers.

This test correctly validates that the containedIn constraint works with nested pointers, which was part of the original issue being fixed. The test structure mirrors the equalTo test, which provides consistency across test cases.

🧰 Tools
🪛 ESLint

[error] 420-420: 'it' is not defined.

(no-undef)


[error] 439-439: 'expect' is not defined.

(no-undef)


442-462: Test confirms that matchesQuery works properly with nested pointers.

This test properly validates that the matchesQuery constraint works with nested pointers, which was part of the original issue being fixed. The test creates a query that matches a Child object by its property, ensuring the nested query functionality is tested correctly.

🧰 Tools
🪛 ESLint

[error] 442-442: 'it' is not defined.

(no-undef)


[error] 461-461: 'expect' is not defined.

(no-undef)


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
spec/MongoStorageAdapter.spec.js (1)

398-462: Consider adding negative test cases

While the current tests verify that the query constraints work correctly when there should be a match, it would be beneficial to also test cases where no match should be found.

For example, you could add a test like:

it('Parse query with containedIn returns no results for non-matching object', async () => {
  const child = new Parse.Object('Child')
  child.set('key','value')
  await child.save();
  
  const nonMatchingChild = new Parse.Object('Child')
  nonMatchingChild.set('key','different_value')
  await nonMatchingChild.save();

  const parent = new Parse.Object('Parent');
  parent.set('some', {
    nested: {
      key: {
        child
      }
    }
  })
  await parent.save();

  const query = await new Parse.Query('Parent')
    .containedIn('some.nested.key.child', [nonMatchingChild])
    .find();

  expect(query.length).toEqual(0);
})
🧰 Tools
🪛 ESLint

[error] 398-398: 'it' is not defined.

(no-undef)


[error] 417-417: 'expect' is not defined.

(no-undef)


[error] 420-420: 'it' is not defined.

(no-undef)


[error] 439-439: 'expect' is not defined.

(no-undef)


[error] 442-442: 'it' is not defined.

(no-undef)


[error] 461-461: 'expect' is not defined.

(no-undef)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e556812 and d4da486.

📒 Files selected for processing (1)
  • spec/MongoStorageAdapter.spec.js (1 hunks)
🧰 Additional context used
🪛 ESLint
spec/MongoStorageAdapter.spec.js

[error] 398-398: 'it' is not defined.

(no-undef)


[error] 417-417: 'expect' is not defined.

(no-undef)


[error] 420-420: 'it' is not defined.

(no-undef)


[error] 439-439: 'expect' is not defined.

(no-undef)


[error] 442-442: 'it' is not defined.

(no-undef)


[error] 461-461: 'expect' is not defined.

(no-undef)

🔇 Additional comments (4)
spec/MongoStorageAdapter.spec.js (4)

393-397: Good documentation

The comment clearly explains the issue being fixed - that nested pointer queries work with equalTo but not with containedIn or matchesQuery. This provides valuable context for understanding the tests that follow.


398-418: Well-structured baseline test

This test establishes a baseline by confirming that equalTo works correctly with nested pointers. The test creates the necessary objects, sets up the nested structure properly, and makes a clear assertion.

🧰 Tools
🪛 ESLint

[error] 398-398: 'it' is not defined.

(no-undef)


[error] 417-417: 'expect' is not defined.

(no-undef)


420-440: Good test for the containedIn fix

This test properly verifies that using containedIn on a nested pointer field works correctly, which addresses part of the issue mentioned in the PR objectives. The structure mirrors the previous test for consistency.

🧰 Tools
🪛 ESLint

[error] 420-420: 'it' is not defined.

(no-undef)


[error] 439-439: 'expect' is not defined.

(no-undef)


442-462: Comprehensive test for matchesQuery functionality

This test effectively verifies that the matchesQuery constraint works properly with nested pointers, completing the coverage of the fix. The comment noting that this internally uses containedIn helps explain the relationship between the tests.

🧰 Tools
🪛 ESLint

[error] 442-442: 'it' is not defined.

(no-undef)


[error] 461-461: 'expect' is not defined.

(no-undef)

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Apr 29, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

@RahulLanjewar93
Copy link
Contributor Author

It cancelled the failing test case action -_-
Can someone re run it so that they can see the actual issue

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
src/Adapters/Storage/Mongo/MongoTransform.js (5)

654-657: Fix for nested object query support in constraints

This change is addressing the core issue in the PR. By accepting the key parameter and checking if it's a nested field (contains a dot), the function can now properly handle query constraints on nested objects.

Note: There is a small typo in the comment: "wether" should be "whether".

- // Check wether the given key has `.`
+ // Check whether the given key has `.`
🧰 Tools
🪛 Biome (1.9.4)

[error] 655-655: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


739-742: Consistently renamed variables in $all handler

The variable renaming is applied throughout the $all constraint handling.

As highlighted by static analysis, consider using Array.isArray() instead of instanceof Array for better compatibility:

-        const arr = constraint[constraintKey];
-        if (!(arr instanceof Array)) {
+        const arr = constraint[constraintKey];
+        if (!Array.isArray(arr)) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 740-740: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


756-757: Renamed variables in regex constraint handling

Variable renamed in the regex constraint handling section.

As noted by static analysis, the variable declaration in a switch case could be improved:

-        var s = constraint[constraintKey];
+        {
+          const s = constraint[constraintKey];
+          if (typeof s !== 'string') {
+            throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad regex: ' + s);
+          }
+          answer[constraintKey] = s;
+        }
-        if (typeof s !== 'string') {
-          throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad regex: ' + s);
-        }
-        answer[constraintKey] = s;

Also applies to: 760-761

🧰 Tools
🪛 Biome (1.9.4)

[error] 756-756: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


764-765: Renamed variables in $containedBy constraint

Variable renaming consistently applied to the $containedBy constraint.

Similar to previous suggestions, consider using Array.isArray():

-        const arr = constraint[constraintKey];
-        if (!(arr instanceof Array)) {
+        const arr = constraint[constraintKey];
+        if (!Array.isArray(arr)) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 765-765: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


850-851: Renamed variables in $within constraint

Variable renaming applied to the $within constraint handler.

As noted by static analysis, this switch clause variable declaration could be wrapped in a block:

-        var box = constraint[constraintKey]['$box'];
+        {
+          const box = constraint[constraintKey]['$box'];
+          if (!box || box.length != 2) {
+            throw new Parse.Error(Parse.Error.INVALID_JSON, 'malformatted $within arg');
+          }
+          answer[constraintKey] = {
+            $box: [
+              [box[0].longitude, box[0].latitude],
+              [box[1].longitude, box[1].latitude],
+            ],
+          };
+        }
-        if (!box || box.length != 2) {
-          throw new Parse.Error(Parse.Error.INVALID_JSON, 'malformatted $within arg');
-        }
-        answer[constraintKey] = {
-          $box: [
-            [box[0].longitude, box[0].latitude],
-            [box[1].longitude, box[1].latitude],
-          ],
-        };

Also applies to: 854-855

🧰 Tools
🪛 Biome (1.9.4)

[error] 850-850: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4da486 and ec45ba0.

📒 Files selected for processing (1)
  • src/Adapters/Storage/Mongo/MongoTransform.js (13 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/Adapters/Storage/Mongo/MongoTransform.js

[error] 655-655: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 724-724: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 740-740: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 756-756: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 850-850: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: Node 18
  • GitHub Check: Node 20
  • GitHub Check: Redis Cache
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: Docker Build
  • GitHub Check: Code Analysis (javascript)
🔇 Additional comments (24)
src/Adapters/Storage/Mongo/MongoTransform.js (24)

329-330: Properly passing the key parameter to transformConstraint

The key is now correctly passed to the transformConstraint function from the transformQueryKeyValue function, which is essential for the fix to work.


661-662: Essential logic to handle nested fields correctly

This is the critical change that fixes the issue with containedIn and matchesQuery constraints for nested objects. By choosing the appropriate transformation function based on whether the field is an array OR the key is nested, nested pointer fields are now properly transformed.


674-675: Variable renaming for clarity

Renaming keys to constraintKeys improves code clarity and avoids confusion with the outer key parameter.


676-677: Variable renaming to prevent shadowing

Good change to avoid shadowing the key parameter with a loop variable. This improves code maintainability and prevents potential bugs.


685-686: Consistent variable renaming

Continuing the variable renaming pattern to use constraintKey instead of key for consistency within the function.


693-694: Consistent variable renaming

Further applied the variable renaming scheme throughout the switch statement.


706-707: Consistent variable renaming

Variable renaming applied to answer[constraintKey].


713-714: Variable renaming in error message

Consistent renaming in the error message string.


717-718: Final value transformation using the appropriate transformer

This line uses the dynamically selected transformer (which now correctly handles nested fields) to transform the value.


745-746: Variable renaming in relationship extraction

Consistent variable renaming applied to the values extraction.


774-775: Renaming for $options constraint

Variable renaming applied to the $options constraint case.


778-779: Renamed variables in $text constraint

Variable renaming applied in the $text constraint handling section.

Also applies to: 785-786


792-793: Renamed variables in $text options

Consistently renamed variables for additional $text search options.

Also applies to: 800-801, 808-809


813-814: Renamed variables in $nearSphere constraint

Variable renaming applied to the $nearSphere constraint.

Also applies to: 819-820


827-828: Renamed variables in $maxDistance

Variable renaming in the $maxDistance constraint handler.


833-834: Renamed variables in distance-related constraints

Variable renaming consistently applied to the distance-related constraints.

Also applies to: 836-837, 839-840


846-847: Renamed variable in error message

Variable renaming applied to the error message for unsupported constraints.


863-865: Renamed variables in $geoWithin constraint

Variable renaming applied to the $geoWithin constraint handler.


901-903: Renamed variables in polygon handling

Variable renaming applied to the polygon portion of $geoWithin.


930-932: Renamed variables in centerSphere handling

Variable renaming applied to the centerSphere portion of $geoWithin.


937-938: Renamed variables in $geoIntersects constraint

Variable renaming applied to the $geoIntersects constraint handler.

Also applies to: 946-952


955-957: Renamed variables in the default case

Variable renaming applied to the default case that handles custom constraints.


654-962: Overall assessment of the changes to fix nested objects in queries

This is a solid, targeted fix for the issue with querying nested objects. The changes:

  1. Add proper detection of nested fields (containing dots)
  2. Use the correct transformation function for nested fields
  3. Consistently rename variables to avoid shadowing and improve clarity

These changes ensure that constraints like containedIn and matchesQuery work properly with nested objects by correctly transforming the query conditions. The thorough renaming of variables also prevents potential bugs that could arise from variable shadowing.

🧰 Tools
🪛 Biome (1.9.4)

[error] 655-655: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 756-756: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 850-850: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 724-724: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 740-740: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 765-765: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 875-875: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 890-890: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 905-905: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 913-913: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


723-726:

✅ Verification successful

Variable renaming for consistency

The renaming is consistently applied throughout the function, including in array value extractions and error messages.


🏁 Script executed:

#!/bin/bash
# Check if there are any remaining instances of unintended 'key' variables that should be 'constraintKey'
# This will help ensure the renaming was comprehensive

rg -A 2 -B 2 "for\s*\(.+\s+key\s+.+\)\s*\{" src/Adapters/Storage/Mongo/MongoTransform.js

Length of output: 181


Variable renaming verified and correct

All instances of constraintKey are used consistently in array access and error messages. The for (var key in mongoObject) loop correctly uses key to iterate over mongoObject properties and does not require renaming.

🧰 Tools
🪛 Biome (1.9.4)

[error] 724-724: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 29, 2025
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 90.47619% with 4 lines in your changes missing coverage. Please review.

Project coverage is 93.00%. Comparing base (e556812) to head (840892e).

Files with missing lines Patch % Lines
src/Adapters/Storage/Mongo/MongoTransform.js 90.47% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #9738      +/-   ##
==========================================
- Coverage   93.01%   93.00%   -0.02%     
==========================================
  Files         187      187              
  Lines       15081    15082       +1     
  Branches      174      174              
==========================================
- Hits        14028    14027       -1     
- Misses       1041     1043       +2     
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 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.

@mtrezza
Copy link
Member

mtrezza commented Apr 29, 2025

Tests should be running now

@RahulLanjewar93
Copy link
Contributor Author

Tests should be running now

i meant the failing test cases were skipped since I pushed a commit before the actions were complete. We need that to see the current behaviour right? Is there a way to retry actions at that specific commit so we can see the failing test cases

@mtrezza
Copy link
Member

mtrezza commented Apr 29, 2025

If you say they failed for you when you ran them locally, then that's fine. I see that all tests are passing now as well, nice!

Signed-off-by: Manuel <[email protected]>
Signed-off-by: Manuel <[email protected]>
Comment on lines -671 to +674
var keys = Object.keys(constraint).sort().reverse();
var constraintKeys = Object.keys(constraint).sort().reverse();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that most changes are just a var renaming form keys to constraintKeys. We aim at minimal code changes unless there is a justified benefit (beyond semantics) to rename the var. If you feel the var needs an explanation, then please add a code comment directly to the var which will also be picked up by the IDE:

/** Explain var. */
var keys = ...

* If we use equalTo to comparse the nested pointer it works
* But it does not work with contained in or matchesQuery
*/
it('queries nested objects using equalTo', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doesn't seem like these tests belong in the MongoStorageAdapter.spec.js file, which is testing the adapter itself. These are just Parse.Query tests and there should be a dedicated file for that.

@mtrezza mtrezza changed the title fix: Fixed issue where containedIn and matchesQuery does not work with nested objects fix: Parse.Query.containedIn and matchesQuery do not work with nested objects Apr 29, 2025
@mtrezza
Copy link
Member

mtrezza commented Apr 29, 2025

Note: it seems that your PR is based on the release branch of your fork, instead of the alpha branch. That doesn't seem to cause any conflicts - surprisingly - but for future PRs, a PR should be based on the same branch as the one it will be merged into.

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.

Support deeply nested pointers in 'containedIn' queries
3 participants