Skip to content
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

fix: Parse.Object.get returns array instead of object if key name is number-like #2201

Merged
merged 15 commits into from
Jul 7, 2024

Conversation

mtrezza
Copy link
Member

@mtrezza mtrezza commented Jul 2, 2024

Pull Request

Issue

Closes: #2198

Approach

Issue demo

Tasks

  • Add tests

Copy link

parse-github-assistant bot commented Jul 2, 2024

Thanks for opening this pull request!

src/ObjectStateMutations.ts Outdated Show resolved Hide resolved
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
@mkmandar123
Copy link

@mtrezza this fix would return wrong output e.g.

  1. { field: 'object', value: { '1x1': 1, '2': 2, '3': 3 } }, return as jsonArray which is wrong
  2. { field: 'object', value: { '1': 1 } }, return as jsonArray which is also wrong as 0 index is missing
    I have created a PR fix: Objects wrongly getting converted to Array #2206 which considers these cases as well.

@mtrezza
Copy link
Member Author

mtrezza commented Jul 5, 2024

An index of 0 is not required for an array to be an array. See #2198 (comment).

src/ObjectStateMutations.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jul 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b50790a) to head (83066f2).
Report is 103 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff             @@
##             alpha     #2201    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           61        64     +3     
  Lines         6186      6358   +172     
  Branches      1499      1528    +29     
==========================================
+ Hits          6186      6358   +172     

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

@mtrezza
Copy link
Member Author

mtrezza commented Jul 7, 2024

@dplewis anything else that should be removed from the changes in https://github.com/parse-community/Parse-SDK-JS/pull/2120/files? Or can we merge

@dplewis
Copy link
Member

dplewis commented Jul 7, 2024

Thats it, this is ready to merge

@mtrezza mtrezza changed the title fix: Parse Object field value converts from object to array if key contains number fix: Parse.Object.get returns array instead of object value if key name is number-like Jul 7, 2024
@mtrezza mtrezza changed the title fix: Parse.Object.get returns array instead of object value if key name is number-like fix: Parse.Object.get returns array instead of object if key name is number-like Jul 7, 2024
@mtrezza mtrezza merged commit 5921ba2 into parse-community:alpha Jul 7, 2024
12 checks passed
@mtrezza mtrezza deleted the fix/json-array branch July 7, 2024 12:46
parseplatformorg pushed a commit that referenced this pull request Jul 7, 2024
# [5.3.0-alpha.2](5.3.0-alpha.1...5.3.0-alpha.2) (2024-07-07)

### Bug Fixes

* `Parse.Object.get` returns array instead of object if key name is number-like ([#2201](#2201)) ([5921ba2](5921ba2))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0-alpha.2

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jul 7, 2024
parseplatformorg pushed a commit that referenced this pull request Jul 7, 2024
# [5.3.0-beta.1](5.2.0...5.3.0-beta.1) (2024-07-07)

### Bug Fixes

* `Parse.Object.get` returns array instead of object if key name is number-like ([#2201](#2201)) ([5921ba2](5921ba2))

### Features

* Add support for Node 22 ([#2209](#2209)) ([c74fd4c](c74fd4c))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Jul 7, 2024
parseplatformorg pushed a commit that referenced this pull request Jul 7, 2024
# [5.3.0](5.2.0...5.3.0) (2024-07-07)

### Bug Fixes

* `Parse.Object.get` returns array instead of object if key name is number-like ([#2201](#2201)) ([5921ba2](5921ba2))

### Features

* Add support for Node 22 ([#2209](#2209)) ([c74fd4c](c74fd4c))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Object attributes transformed in array
4 participants