-
-
Notifications
You must be signed in to change notification settings - Fork 205
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: Arrays being set as empty when calling clearUnsavedChanges() #1039
base: master
Are you sure you want to change the base?
fix: Arrays being set as empty when calling clearUnsavedChanges() #1039
Conversation
This fixes the issue because the **_handleSingleResult()** function which handles the response for a single parse object in the **_ParseResponseBuilder** was calling **_notifyChildrenAboutSave();** so when **save()** was called on any object it called **_notifyChildrenAboutSaving();** first and then in the response when **_notifyChildrenAboutSave();** was called, the **_estimatedArrayBeforeSaving** had values and _savedArray was not set as empty. But in case of other queries where single object was returned like **getUpdatedUser()** or **fetch()** on any object it just called **_notifyChildrenAboutSave();** in the **_handleSingleResult()** function which resulted in **_savedArray** being set as empty since **_estimatedArrayBeforeSaving** was null. I just added the null safety and not empty check before setting the **_savedArray** to **_estimatedArrayBeforeSaving** so now the savedArray is never returned empty in the response and the issue is resolved.
🚀 Thanks for opening this pull request! |
I will reformat the title to use the proper commit message syntax. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Could you add a test ?
How to do that?
…On Sat, Mar 22, 2025, 10:22 AM Mohammad Bagher Fakouri < ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Looks good. Could you add a test ?
—
Reply to this email directly, view it on GitHub
<#1039 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AY6HMS7WCHAMJBEKI3GLEKT2VTXRZAVCNFSM6AAAAABZRD7BXCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDOMBXHAZDONJQGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Please check the examples in the link below: https://github.com/parse-community/Parse-SDK-Flutter/tree/master/packages/dart/test |
I have seen the example. I can't seem to figure it out, I'm still a rookie developer. Can you do it yourself? |
When will it be merged? |
@nabos440 To add a test, just clone an existing test from the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1039 +/- ##
==========================================
- Coverage 43.37% 9.53% -33.84%
==========================================
Files 61 8 -53
Lines 3463 325 -3138
==========================================
- Hits 1502 31 -1471
+ Misses 1961 294 -1667 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
They are failing because of codcov report upload failure and lint issue for which there is no detail as to what is causing the failure |
If you run |
Pull Request
Issue
Closes: #1038
Approach
Added null safety check before clearing savedArray and setting to _estimatedArrayBeforeSaving in the onSaved() function of Parse Array class
This fixes the issue because the _handleSingleResult() function which handles the response for a single parse object in the _ParseResponseBuilder was calling _notifyChildrenAboutSave(); so when save() was called on any object it called _notifyChildrenAboutSaving(); first and then in the response when _notifyChildrenAboutSave(); was called, the _estimatedArrayBeforeSaving had values and _savedArray was not set as empty.
But in case of other queries where single object was returned like getUpdatedUser() or fetch() on any object it just called _notifyChildrenAboutSave(); in the _handleSingleResult() function which resulted in _savedArray being set as empty since _estimatedArrayBeforeSaving was null. I just added the null safety check before setting the _savedArray to _estimatedArrayBeforeSaving so now the savedArray is never returned empty in the response and the issue is resolved.