-
-
Notifications
You must be signed in to change notification settings - Fork 206
Custom Objects: Problems with Queries, non-primitive fields (Pointers, Relation, File, GeoPoint) #128
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
Comments
Sorry, just reading slowly through this. Subtyping ParseObjects and referencing them in another subtype of ParseObject requires something along the lines of this to be correctly deserialised.
|
Hi @danibjor Try use my Fork: parse_server_sdk:
git:
url: https://github.com/rodrigosmarques/flutter_parse_sdk.git
ref: bugfix-parsequery-parsefile-parseuser-parseencoder |
My code that was working and work in my Fork import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:path_provider/path_provider.dart';
import 'package:flutter/material.dart';
import 'package:parse_server_sdk/parse_server_sdk.dart';
Future<File> _downloadFile(String url, String filename) async {
http.Client _client = new http.Client();
var req = await _client.get(Uri.parse(url));
var bytes = req.bodyBytes;
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/$filename');
await file.writeAsBytes(bytes);
return file;
}
void main() async {
Parse().initialize("HIn4bvCmAYvwpDmPTmRjfoSwpTPPmGsPUMKYU36Q",
"xxxxxxx",
clientKey: "ggD2i3GejX3SIxpDgSbKHHV8uHUUP3QGiPPTlmPK",
autoSendSessionId: true,
debug: true,
liveQueryUrl: "xxxxxxx");
final localUser = await ParseUser.currentUser();
final user = ParseUser(
"user", "password", "[email protected]");
var response = await user.login();
if (response.success) {
print("Login sucess");
} else {
print("Login error");
}
var point =
ParseGeoPoint(debug: true, latitude: -20.2523818, longitude: -40.2665611);
var point2 =
ParseGeoPoint(debug: true, latitude: -19.2523818, longitude: -41.2665611);
QueryBuilder<ParseUser> queryBuilder = QueryBuilder<ParseUser>(
ParseUser.forQuery())
..orderByAscending("runCount")
..setLimit(1000)
..whereGreaterThan("runCount", 1)
..whereLessThan("runCount", 1000)
..whereEqualTo("tipo", "D")
..whereNear("localizacao", point)
//..whereEqualTo("usuario", user)
..whereGreaterThan("createdAt", DateTime.now().subtract(Duration(days: 60)))
..whereLessThan("createdAt", DateTime.now());
//..whereEqualTo("createdAt", DateTime.now());
//..whereStartsWith("cidade", "Vit");
//..whereContains("keywords", "leite");
//..whereGreaterThan("tipo", "A")
//..whereGreaterThan("runCount", 0);
//..whereWithinMiles("localizacao", point, 5);
//..whereWithinKilometers("localizacao", point, 50);
//..whereWithinRadians("localizacao", point, 1);
//..whereWithinGeoBox("localizacao", point, point2);
var apiResponse = await queryBuilder.query();
if (apiResponse.success && apiResponse.result != null) {
print(
"Result: ${((apiResponse.result as List<dynamic>).first as ParseObject).toString()}");
} else {
print("Result: ${apiResponse.error.message}");
}
final listUsers = await apiResponse.result;
if (listUsers != null) {
print(listUsers.length); //print(listUsers[0].toString());
}
var file = await _downloadFile(
"https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png",
"image.png");
var parseFile = ParseFile(file, name: "image.png", debug: true);
//var parseFile = ParseFile(null, url: "https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png", name: "image.png", debug: true);
var fileResponse = await parseFile.save();
if (fileResponse.success) {}
await parseFile.download();
var parseObject = ParseObject("TestAPI", debug: true);
parseObject.set<String>("stringName", "Name");
parseObject.set<double>("doubleNumber", 1.5);
parseObject.set<int>("intNumber", 0);
parseObject.set<bool>("boolFound", true);
parseObject.set<List<String>>("listString", ["a", "b", "c", "d"]);
parseObject.set<List<int>>("listNumber", [0, 1]);
parseObject.set<DateTime>("dateTest", DateTime.now());
parseObject.set<Map<String, dynamic>>(
"jsonTest", {"field1": "value1", "field2": "value2"});
parseObject.setIncrement("intNumber2", 2);
parseObject.setDecrement("intNumber3", 2);
parseObject.set<ParseGeoPoint>(
"location", ParseGeoPoint(latitude: -20.2523818, longitude: -40.2665611));
parseObject.set<ParseUser>("user", user);
parseObject.set<List<ParseUser>>("users", [user, user]);
parseObject.set<ParseFile>("fileImage", parseFile);
parseObject.set<List<ParseFile>>("fileImages", [parseFile, parseFile]);
apiResponse = await parseObject.save();
if (apiResponse.success) {
print("Objeto JSON: " + (apiResponse.result as ParseObject).toString());
} else {
print("Error: " + apiResponse.error.toString());
return;
}
parseObject.setRemove("listString", ["a"]);
apiResponse = await parseObject.save();
if (apiResponse.success) {
print("Objeto JSON: " + (apiResponse.result as ParseObject).toString());
parseObject.objectId = (apiResponse.result as ParseObject).objectId;
} else {
print("Error: " + apiResponse.error.toString());
return;
}
parseObject.setRemoveAll("listString", ["b", "c"]);
apiResponse = await parseObject.save();
if (apiResponse.success) {
print("Objeto JSON: " + (apiResponse.result as ParseObject).toString());
parseObject.objectId = (apiResponse.result as ParseObject).objectId;
} else {
print("Error: " + apiResponse.error.toString());
return;
}
parseObject.setAdd("listString", ["a"]);
apiResponse = await parseObject.save();
if (apiResponse.success) {
print("Objeto JSON: " + (apiResponse.result as ParseObject).toString());
parseObject.objectId = (apiResponse.result as ParseObject).objectId;
} else {
print("Error: " + apiResponse.error.toString());
return;
}
parseObject.setAddAll("listString", ["b", "c"]);
apiResponse = await parseObject.save();
if (apiResponse.success) {
print("Objeto JSON: " + (apiResponse.result as ParseObject).toString());
parseObject.objectId = (apiResponse.result as ParseObject).objectId;
} else {
print("Error: " + apiResponse.error.toString());
return;
}
parseObject.setAddUnique("listString", ["a", "b", "c", "d", "e"]);
apiResponse = await parseObject.save();
if (apiResponse.success) {
print("Objeto JSON: " + (apiResponse.result as ParseObject).toString());
parseObject.objectId = (apiResponse.result as ParseObject).objectId;
} else {
print("Error: " + apiResponse.error.toString());
return;
}
var instalattion = await ParseInstallation.currentInstallation();
instalattion.deviceToken = "xyz";
instalattion.set<ParseUser>("usuario", user);
instalattion.subscribeToChannel("C");
instalattion.subscribeToChannel("D");
instalattion.subscribeToChannel("E");
apiResponse = await instalattion.save();
if (apiResponse.success && apiResponse.result != null) {
print("Result: ${((apiResponse.result) as ParseObject).toString()}");
} else {
print("Result: ${apiResponse.error.message}");
}
instalattion.unsubscribeFromChannel("D");
apiResponse = await instalattion.save();
var listChannels = await instalattion.getSubscribedChannels();
var apiResponseUser = await ParseObject('_User').getObject('b72MScHoSj');
if (apiResponse.success) {
var usuario = apiResponseUser.result as ParseObject;
if (usuario != null) {
var queryBuilder2 = QueryBuilder<ParseObject>(ParseObject('Produto'))
..whereEqualTo("owner", usuario.toPointer());
var apiResponse2 = await queryBuilder2.query();
if (apiResponse2.success && apiResponse2.result != null) {
print(
"Result: ${((apiResponse2.result as List<dynamic>).first as ParseObject).toString()}");
} else {
print("Result: ${apiResponse2.error.message}");
}
await usuario.pin();
var usuarioPion = await usuario.fromPin(usuario.objectId);
print(usuarioPion.toString());
}
}
if (user != null) {
await user.logout(deleteLocalUserData: false);
}
print("Fim");
runApp(MyApp());
}
|
So to confirm, ParseFile and subtyping ParseObjects seems to not work? |
Yes, not working. Stopped. On my Fork you do not have your latest release and I have everything working. |
Well pull the latest commits first. I have unit tests my end with everything working. Nothing major has changed in ParseFile. |
@phillwiggins your example of overriding Still to go: Database columns of type |
@RodrigoSMarques correct your merge requests and create a new pull request. It doesn't look like a lot of the merge you created was actually added. @danibjor In all honesty I've not had chance to look at relations, although look at the line:- , this wouldn't work as you are referencing a ParseObject rather than a List. Something like:- |
@phillwiggins Might be relational stuff in general. Have to dig deeper. |
Okay cool. Looks like the merge request has caused a few issues. @RodrigoSMarques update your current project and create a null PR. Should all be working then. |
After further review it looks like Relation in general is not working...
So on tests made using Rodrigo's branch, it's just ParseFile that needs
taking from that fix and adding to 1.0.16 or was there anything else that
needs taking from that branch?
…On Mon, Mar 18, 2019, 13:37 Daniel Bjørnbakk ***@***.***> wrote:
@phillwiggins <https://github.com/phillwiggins>
myObject._objectData['relationColumn'] is null in the "working"
repo/branch @RodrigoSMarques <https://github.com/rodrigosmarques> asked
me to test. Pointers works on that branch.
Might be relational stuff in general. Have to dig deeper.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3shIyif4DMK_A4HBo3ac0WiT3X8Mks5vX5aagaJpZM4b5tSF>
.
On Mon, Mar 18, 2019, 13:37 Daniel Bjørnbakk ***@***.***> wrote:
@phillwiggins <https://github.com/phillwiggins>
myObject._objectData['relationColumn'] is null in the "working"
repo/branch @RodrigoSMarques <https://github.com/rodrigosmarques> asked
me to test. Pointers works on that branch.
Might be relational stuff in general. Have to dig deeper.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3shIyif4DMK_A4HBo3ac0WiT3X8Mks5vX5aagaJpZM4b5tSF>
.
|
@phillwiggins ParseFile its working for me. Upload, Download e get in my Fork |
Your fork is heavily outdated. It wasn't up to date when your PR was put
through, hence why merge conflicts and the merge process have broke it.
…On Mon, Mar 18, 2019, 15:02 Rodrigo de Souza Marques < ***@***.***> wrote:
@phillwiggins <https://github.com/phillwiggins> ParseFile its working for
me. Upload, Download e get in my Fork
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3szzcn_kxpo0gBZNh8Zq1gaJyNaqks5vX6p_gaJpZM4b5tSF>
.
|
I've made some corrections on ParseFile. Does this now fix the problem? |
Let's do this. I will update my fork with your changes and I make bugfix than find error. As my example app, it performs tests of all operations I can identify the problem. |
Perfect, if you could that would be great.
…On Mon, 18 Mar 2019 at 17:33, Rodrigo de Souza Marques < ***@***.***> wrote:
Let's do this. I will update my fork with your changes and I make bugfix
than find error.
As my example app, it performs tests of all operations I can identify the
problem.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3l6jw0a20sPZ5Ng_Jp6dlBPYmXRwks5vX83rgaJpZM4b5tSF>
.
--
Kind Regards
Phill Wiggins
[email protected]
|
I created the PR #131 with code changes that went back to working on my test project. ParseFie = upload, download, retrieve Favor avaliar. |
I appreciate your efforts Rodrigo but again, please work from the latest
branch. The PR is for master so there will be many merge conflicts, and
please can you remove all redundant code. There only 2 minor changes out of
the entire PR. The rest is mostly already done or unnecessary code.
…On Tue, Mar 19, 2019, 04:41 Rodrigo de Souza Marques < ***@***.***> wrote:
@phillwiggins <https://github.com/phillwiggins>
I created the PR #131
<#131> with code
changes that went back to working on my test project.
ParseFie = upload, download, retrieve
ParseGeopoint = save, retrieve
ParseQuery = Pointer, DateTime, String
ParseInstallation = Save, retrieve
Favor avaliar.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3lOET2hewey3VysaayWLggSQXUfyks5vYGqXgaJpZM4b5tSF>
.
|
@phillwiggins I do not know what I might have done wrong. |
Did you pull branch from master rather than the branch labelled v1.0.16.
It's not a big issue, it just can cause conflicts like it did last time
around
…On Tue, Mar 19, 2019, 12:22 Rodrigo de Souza Marques < ***@***.***> wrote:
@phillwiggins <https://github.com/phillwiggins>
Yesterday, I deleted the fork that existed and created another one from
its code that was available. This was yesterday at 19:55 (GMT).
I do not know what I might have done wrong.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3i8qm4tqe5EuvPHMLtWjliMkM2FIks5vYNZsgaJpZM4b5tSF>
.
|
OK. I'll make a PR of your code for the fork and handle the changes. Please do not close my PR for now. As it has a history of the changes made and you may have to redo after the merge of the code. |
That's fine.
Again, thank you for your help.
…On Tue, Mar 19, 2019, 12:36 Rodrigo de Souza Marques < ***@***.***> wrote:
OK. I'll make a PR of your code for the fork and handle the changes.
Please do not close my PR for now. As it has a history of the changes made
and you may have to redo after the merge of the code.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3giM6YxpiUaWImN9qN_KmK6-iO_bks5vYNnhgaJpZM4b5tSF>
.
|
Created new PR #132 |
Can you do a test using my Fork to make sure it's working? The master is updated with the changes. pubspec.yaml dependencies:
flutter:
sdk: flutter
parse_server_sdk:
git: git://github.com/rodrigosmarques/flutter_parse_sdk.git |
@RodrigoSMarques have done some tests that failed previously:
Stuff on objects that broke, tested:
object.relation don't work - but was expected as it's not (fully?) implemented. @phillwiggins @RodrigoSMarques: I think we should have a go at this one. Edit: |
@danibjor Can you tell me more about object.relation. This would be: https://docs.parseplatform.org/rest/guide/#relational-queries InQuery and notInQuery operators? I'm starting to study the implementation because I also need them in my application. @phillwiggins Do you intend to implement new features? I ask you not to duplicate things. I intend to simplify the use of ACLs, complete other queries with Geopoint e Relational Queries |
@RodrigoSMarques my bad - not constraining queries on column of type @phillwiggins ditto on Slack. |
Hey Rodrigo
Send me your email address to [email protected]
I don't have any current plans really. I'm happy for you to work on them.
…On Tue, Mar 19, 2019, 15:07 Rodrigo de Souza Marques < ***@***.***> wrote:
@danibjor <https://github.com/danibjor>
Thank you for your feedback.
Can you tell me more about object.relation.
This would be:
https://docs.parseplatform.org/rest/guide/#relational-queries
InQuery operators and notInQuery?
I'm starting to study the implementation because I also need them in my
application.
@phillwiggins <https://github.com/phillwiggins>
How do I join Slack?
Do you intend to implement new features? I ask you not to duplicate things.
I intend to simplify the use of ACLs, complete other queries with Geopoint
e Relational Queries
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3oQ40umK-gT4tGjPCy6V85UIqkk0ks5vYP1LgaJpZM4b5tSF>
.
|
@danibjor Can you give me an example with native code (ios / Android) or indicate this in the documentation? I have not worked with ParseRelation and I do not know how it works |
Where pointers are one-to-one relations, Relation is one-to-many. Or collection of pointers you may say.
Player->[Skills]
http://docs.parseplatform.org/android/guide/#relations
-
… 19. mar. 2019 kl. 18:20 skrev Rodrigo de Souza Marques ***@***.***>:
@danibjor
I did not understand.
Can you give me an example with native code (ios / Android) or indicate this in the documentation?
I have not worked with ParseRelation and I do not know how it works
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@danibjor, |
@phillwiggins |
@phillwiggins Resolved in the last release. @danibjor |
Tested on v1.0.16 branch.
Seems to be issues with non primitive fields.
ParseFile
is missing values on propertiesfile
,name
andurl
(value isnull
). But if you inspect the object, bothname
andurl
are in the_objectData
Map.Sub classing ParseObject gives Type Conversion Exceptions on non primitive fields.
ParseFile
This is result from

QueryBuilder<Store>
on Store Table.Result is
List<ParseObject>
, runtime showsList<Store>
List<Store> stores = response.result;
// throws exception: _TypeError (typeList<ParseObject>
is not a subtype of typeList<Store>
)List<Store> stores = (response.result as List<ParseObject>).cast<Store>();
// works - but hackyStore.city is Pointer to City class/table:
City get city => get<City>('city')
Store table:

myParseObject.get<ParseObject>('customers')
returns single object - should returnList<>
Complete test example (file new flutter project, add dependency to sdk 1.0.16):
config.dart: (pm me to get access to the test site - don't want spambots to fill the database)
main.dart:
The text was updated successfully, but these errors were encountered: