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: Updating and deleting a ParseObject sends requests even if object ID is null #829

Merged
merged 5 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/dart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [3.1.15](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.14...dart-3.1.15) (2023-02-28)

### Bug Fixes

* Updating and deleting a ParseObject sends requests even if object ID is null ([#829](https://github.com/parse-community/Parse-SDK-Flutter/pull/829))

## [3.1.14](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.13...dart-3.1.14) (2023-02-26)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/dart/lib/src/base/parse_constants.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of flutter_parse_sdk;

// Library
const String keySdkVersion = '3.1.14';
const String keySdkVersion = '3.1.15';
const String keyLibraryName = 'Flutter Parse SDK';

// End Points
Expand Down
26 changes: 24 additions & 2 deletions packages/dart/lib/src/objects/parse_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ class ParseObject extends ParseBase implements ParseCloneable {
}

Future<ParseResponse> update() async {
assert(
objectId != null && (objectId?.isNotEmpty ?? false),
"Can't update a parse object while the objectId property is null or empty",
);

try {
final Uri url = getSanitisedUri(_client, '$_path/$objectId');
final String body = json.encode(toJson(forApiRQ: true));
Expand Down Expand Up @@ -443,8 +448,25 @@ class ParseObject extends ParseBase implements ParseCloneable {
}

/// Deletes the current object locally and online
Future<ParseResponse> delete<T extends ParseObject>(
{String? id, String? path}) async {
Future<ParseResponse> delete<T extends ParseObject>({
String? id,
String? path,
}) async {
assert(() {
final objId = objectId;
final isNotValidObjectId = objId == null || objId.isEmpty;
final isNotValidIdArg = id == null || id.isEmpty;

if (isNotValidObjectId && isNotValidIdArg) {
throw Exception(
"Can't delete a parse object while the objectId property "
"and id argument is null or empty",
);
}

return true;
}());

try {
path ??= _path;
id ??= objectId;
Expand Down
2 changes: 1 addition & 1 deletion packages/dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: parse_server_sdk
description: Dart plugin for Parse Server, (https://parseplatform.org), (https://back4app.com)
version: 3.1.14
version: 3.1.15
homepage: https://github.com/parse-community/Parse-SDK-Flutter

environment:
Expand Down