Parse-SDK-Flutter
Parse-SDK-Flutter copied to clipboard
ParseRelation#query - Unhandled Exception: type 'ParseObject' is not a subtype of type *
New Issue Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
- [x] I can reproduce the issue with the latest version of Parse Server and the Parse Flutter SDK.
Issue Description
When i get a ParseRelation(relation
) from a subClass of ParseObject, then build a QueryBuilder(queryBuilder
) by relation.getQuery()
, and invoke builder.query<Wallet>()
to get a response. at this time i get some error.
E/flutter ( 7948): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'ParseObject' is not a subtype of type 'Wallet'
E/flutter ( 7948): #0 _ParseResponseBuilder._handleSuccess (package:parse_server_sdk/src/objects/response/parse_response_builder.dart:93:59)
E/flutter ( 7948): #1 _ParseResponseBuilder.handleResponse (package:parse_server_sdk/src/objects/response/parse_response_builder.dart:29:14)
E/flutter ( 7948): #2 handleResponse (package:parse_server_sdk/src/objects/response/parse_response_utils.dart:8:31)
E/flutter ( 7948): #3 ParseObject.query (package:parse_server_sdk/src/objects/parse_object.dart:419:14)
Steps to reproduce
class Plan extends ParseObject {
...
}
final plan = ...;
ParseRelation<Wallet> relation = plan.getRelation("wallets");
QueryBuilder builder = relation.getQuery();
final response = await builder.query<Wallet>();
if (response.success) {
// do something
}
Actual Outcome
Unhandled Exception: type 'ParseObject' is not a subtype of type 'Wallet'
Expected Outcome
query success and get a list of Wallet
Environment
parse_server_sdk_flutter: 3.1.0
Parse Flutter SDK
- SDK version:
3.1.0
- Operating system version:
android
Server
- Parse Server version:
3.1.0
Logs
None
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.
other BUG
final plan = ...;
ParseRelation<Wallet> relation = plan.getRelation("wallets"); // This will be ok
relation.add(someWallet); // or plan.addRelation("wallets", [someWallets]);
ParseRelation<Wallet> relation = plan.getRelation("wallets"); // Bad
Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'ParseRelation<ParseObject>?' in type cast
ParseObject#addRelation
will modify the type of value _objectData['wallets']
.
other BUG
final plan = ...; ParseRelation<Wallet> relation = plan.getRelation("wallets"); // This will be ok relation.add(someWallet); // or plan.addRelation("wallets", [someWallets]); ParseRelation<Wallet> relation = plan.getRelation("wallets"); // Bad
Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'ParseRelation<ParseObject>?' in type cast
ParseObject#addRelation
will modify the type of value_objectData['wallets']
.
Is my usage wrong? The ParseObject's _objectData
is terrible, sometime it's include key - value
, sometime it's include key - operation command
.
https://github.com/parse-community/Parse-SDK-Flutter/blob/11142322d44f60e230ab16c930df092c265b6388/packages/dart/lib/src/objects/parse_base.dart#L188-L204
Is it necessary to save data to _getObjectData()['key']
?
And it's probably to save data to _unsavedChanges['key']
? just like this,
void set<T>(String key, T value, {bool forceUpdate = true}) {
// if (_getObjectData().containsKey(key)) {
// if (_getObjectData()[key] == value && !forceUpdate) {
// return;
// }
// _getObjectData()[key] =
// ParseMergeTool().mergeWithPrevious(_unsavedChanges[key], value);
// } else {
// _getObjectData()[key] = value;
// }
_unsavedChanges[key] = ParseMergeTool().mergeWithPrevious(_unsavedChanges[key], value);
}
Hey guys, I got this error. I spend two hours to be sure can it was not my fault, and after I found this issue.
Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'ParseRelation<ParseObject>?' in type cast
I downloaded the repo and tried to see if the bug was been resolved, but unfortunately, it isn't.
I tried both the HEAD and #762 versions of the code, but nothing worked.
Can you help me?
Thanks a lot for your work!
final plan = ...; ParseRelation<Wallet> relation = plan.getRelation("wallets"); // This will be ok relation.add(someWallet); // or plan.addRelation("wallets", [someWallets]); ParseRelation<Wallet> relation = plan.getRelation("wallets"); // Bad
Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'ParseRelation<ParseObject>?' in type cast
Fix via #860