Parse-SDK-Flutter icon indicating copy to clipboard operation
Parse-SDK-Flutter copied to clipboard

calling clearUnsavedChanges() sets the arrays as empty on the user object

Open nabos440 opened this issue 9 months ago • 2 comments

New Issue Checklist

Issue Description

When I call clearUnsavedChanges() on the user object it sets the arrays as empty. After looking deeper into the issue I found out the response that is returned when you call getUpdatedUser() or query the user has savedArray as empty in the Parse Array class that is returned as part of the response but estimatedArray has all the values. But if you call user.save() and check its response both the estimatedArray and savedArray has values. So, when you call clearUnsavedChanges() on the returned user object through user.save() the arrays remain as it is and not set as empty. The issue might be because of savedArray being returned as empty in the Parse Array class and when clearUnsavedChanges() is called it calls onClearUnsaved() method in Parse Array class which sets the estimatedArray = savedArray so when savedArray is empty the whole array is set as empty. I'm not sure if it's an actual issue or I'm doing something wrong.

Steps to reproduce

Just call clearUnsavedChanges() on the parse user object and print the user as string in the console and all the arrays will be empty and then query the user or call getUpdatedUser() and the savedArray will be empty for every Parse Array class that is returned as response. And then call user.save() and check its response, it will have values in both estimatedArray and savedArray and then call clearUnsavedChanges() on the returned user through response.results.first and arrays will remain as it is.

Actual Outcome

clearUnsavedChanges() sets the arrays as empty and getUpdatedUser() or query user returns savedArray as empty in Parse Array class

Expected Outcome

clearUnsavedChanges() should only clear the unsaved changes and getUpdatedUser() or query user should return values in both estimatedArray and savedArray

Environment

Flutter 3.29.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision 09de023485 (3 weeks ago) • 2025-02-28 13:44:05 -0800 Engine • revision 871f65ac1b Tools • Dart 3.7.0 • DevTools 2.42.2

Parse Flutter SDK

  • SDK version: 9.0.0
  • Flutter version: 3.29.1
  • Dart version: 3.7.0
  • Operating system version: Windows 10

Server

  • Parse Server version: 6.2.0

Logs

nabos440 avatar Mar 20 '25 05:03 nabos440

🚀 Thanks for opening this issue!

ℹ️ You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.