Skip to content

Fix OrderBy multiple columns #241

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

Merged
merged 4 commits into from
Aug 7, 2019
Merged

Fix OrderBy multiple columns #241

merged 4 commits into from
Aug 7, 2019

Conversation

RodrigoSMarques
Copy link
Contributor

Fix OrderBy multiple columns

@phillwiggins phillwiggins merged commit 6dc5231 into parse-community:release/1.0.23 Aug 7, 2019
@pastordee
Copy link
Contributor

OrderBy is not working any more
when you have more than one OrderBy I get this error
flutter: NoSuchMethodError: The method '+' was called on null.
Receiver: null
Tried calling: +(",")

and when OrderBy is just one query don't show and know error shows.

@RodrigoSMarques
Copy link
Contributor Author

This is strange. See my debug.

My query:

  QueryBuilder<ParseUser> queryBuilder =
      QueryBuilder<ParseUser>(ParseUser.forQuery())
        ..orderByAscending("runCount")
        ..orderByAscending('createdAt')
        ..orderByDescending('updatedAt')
        ..whereEqualTo("tipo", "D")
        ..whereGreaterThanOrEqualsTo(
           "createdAt", DateTime.now().subtract(Duration(days: 90)))
        ..whereLessThanOrEqualTo("createdAt", DateTime.now());
  apiResponse = await queryBuilder.query();

Debug Parse Query. 3 fields on order by
Captura de Tela 2019-08-07 às 17 21 04
Captura de Tela 2019-08-07 às 17 21 53
Captura de Tela 2019-08-07 às 17 22 24

Curl, see order on final URL

curl -X GET -H 'user-agent: Flutter Parse SDK 1.0.23' -H 'X-Parse-Application-Id: xxxxxxxxxxxx' -H 'X-Parse-Session-Token: xxxxxxxxxx' -H 'X-Parse-Client-Key: xxxxxxxxxx' https://xxx.xxxx.xxx/1/classes/_User?where=%7B%22tipo%22:%20%22D%22,%22createdAt%22:%7B%20%22$gte%22:%7B%22__type%22:%22Date%22,%22iso%22:%222019-05-09T20:22:30.782Z%22%7D,%20%22$lte%22:%7B%22__type%22:%22Date%22,%22iso%22:%222019-08-07T20:22:30.784Z%22%7D%7D%7D&order=runCount,createdAt,-updatedAt

@pastordee
Copy link
Contributor

var queryBuilder = QueryBuilder(User(null, null,null))
..setAmountToSkip(pageIndex)
..setLimit(pageLimit)
..whereNotContainedIn("objectId", globals.user.buddies)
..orderByAscending(User.keyOnline)
..orderByDescending(User.keyLastSeen);
final prayersResponse = await queryBuilder.query();

I have done everything and is still not work.

@RodrigoSMarques
Copy link
Contributor Author

@pastordee
Is User a custom object?
Was it working before my PR?
Before the query, what is the result for User.keyOnline and User.keyLastSeen?
Does this contain the value or name of the field?

print(User.keyOnline);print(User.keyLastSeen);

@pastordee
Copy link
Contributor

hi thanks for your quick reply

I remove this two lines
..setAmountToSkip(pageIndex)
..setLimit(pageLimit)
and it works perfectly

@RodrigoSMarques
Copy link
Contributor Author

@pastordee
I will test with these conditions. It may actually have an error.

@pastordee
Copy link
Contributor

@RodrigoSMarques
Thanks

@RodrigoSMarques
Copy link
Contributor Author

@pastordee
There really is an error.
I'm making adjustments

@RodrigoSMarques
Copy link
Contributor Author

@pastordee
New PR #243

@pastordee
Copy link
Contributor

pastordee commented Aug 7, 2019

@RodrigoSMarques
Nice one is all work fine thanks.

WangPerryWPY pushed a commit to WangPerryWPY/flutter_parse_sdk that referenced this pull request Aug 9, 2019
This was referenced Aug 9, 2019
fischerscode pushed a commit to fischerscode/Parse-SDK-Flutter that referenced this pull request Sep 5, 2020
* fix some issues

* Update README.md

* Fix OrderBy multiple columns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants