Skip to content

Commit a19ea87

Browse files
authored
fix: Updating and deleting a ParseObject sends requests even if object ID is null (#829)
1 parent 9ff9794 commit a19ea87

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

packages/dart/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [3.1.15](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.14...dart-3.1.15) (2023-02-28)
2+
3+
### Bug Fixes
4+
5+
* Updating and deleting a ParseObject sends requests even if object ID is null ([#829](https://github.com/parse-community/Parse-SDK-Flutter/pull/829))
6+
17
## [3.1.14](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.13...dart-3.1.14) (2023-02-26)
28

39
### Bug Fixes

packages/dart/lib/src/base/parse_constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of flutter_parse_sdk;
22

33
// Library
4-
const String keySdkVersion = '3.1.14';
4+
const String keySdkVersion = '3.1.15';
55
const String keyLibraryName = 'Flutter Parse SDK';
66

77
// End Points

packages/dart/lib/src/objects/parse_object.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ class ParseObject extends ParseBase implements ParseCloneable {
8686
}
8787

8888
Future<ParseResponse> update() async {
89+
assert(
90+
objectId != null && (objectId?.isNotEmpty ?? false),
91+
"Can't update a parse object while the objectId property is null or empty",
92+
);
93+
8994
try {
9095
final Uri url = getSanitisedUri(_client, '$_path/$objectId');
9196
final String body = json.encode(toJson(forApiRQ: true));
@@ -443,8 +448,25 @@ class ParseObject extends ParseBase implements ParseCloneable {
443448
}
444449

445450
/// Deletes the current object locally and online
446-
Future<ParseResponse> delete<T extends ParseObject>(
447-
{String? id, String? path}) async {
451+
Future<ParseResponse> delete<T extends ParseObject>({
452+
String? id,
453+
String? path,
454+
}) async {
455+
assert(() {
456+
final objId = objectId;
457+
final isNotValidObjectId = objId == null || objId.isEmpty;
458+
final isNotValidIdArg = id == null || id.isEmpty;
459+
460+
if (isNotValidObjectId && isNotValidIdArg) {
461+
throw Exception(
462+
"Can't delete a parse object while the objectId property "
463+
"and id argument is null or empty",
464+
);
465+
}
466+
467+
return true;
468+
}());
469+
448470
try {
449471
path ??= _path;
450472
id ??= objectId;

packages/dart/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: parse_server_sdk
22
description: Dart plugin for Parse Server, (https://parseplatform.org), (https://back4app.com)
3-
version: 3.1.14
3+
version: 3.1.15
44
homepage: https://github.com/parse-community/Parse-SDK-Flutter
55

66
environment:

0 commit comments

Comments
 (0)