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

Problem with ParseQuery and DateTime #115

Closed
RodrigoSMarques opened this issue Mar 12, 2019 · 12 comments
Closed

Problem with ParseQuery and DateTime #115

RodrigoSMarques opened this issue Mar 12, 2019 · 12 comments

Comments

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Mar 12, 2019

I found a problem using ParseQuery with DateTime.
When sending the DateTime to the query it is not being coded correctly.

  var queryBuilder = QueryBuilder<ParseObject>(ParseObject('_User'))
    ..whereGreaterThan("createdAt", DateTime.now().subtract(Duration(days: 30)))
    ..whereLessThan("createdAt", DateTime.now());
  var apiResponse = await queryBuilder.query();

Captura de Tela 2019-03-12 às 11 15 41

DateTime in Parse Server is Map

{
  "__type": "Date",
  "iso": "2011-08-21T18:02:52.249Z"
}

I changed the function convertValueToCorrectType to return map, but the MapEntry function returns a String with the conditions of the query

@phillwiggins
Copy link
Member

I'll check this out tonight.

I wrote this library due to it not being available for a project, since I started I've not been able to find time to use this library. I started last night and have found a few bugs. I'll be continuing to work from the release 1.0.16 branch, hopefully will fix that shortly.

@RodrigoSMarques
Copy link
Contributor Author

Hello,
I started an analysis and will probably have to change a lot in ParseQuery. The query parameters must be encoded as a Map, to be correctly encoded in the request in json format. You can use parseEncode to transform to the correct types and send to http using queryParameters. But for this all query possibilities, must be converted to Map and today are as string. It will be a great job, but the library will be perfect.

If I can evolve in the analysis, I keep you informed.

@phillwiggins
Copy link
Member

phillwiggins commented Mar 14, 2019 via email

@RodrigoSMarques
Copy link
Contributor Author

Resolved in Pull Request #123 . Waiting for the merge

@danibjor
Copy link

Seem to work fine in 1.0.16 (should be pushed to Dart packages repo? Latest is .15).
Tested on both custom date column and built in createdAt

    var queryBuilder = QueryBuilder<Store>(Store());
    queryBuilder.whereGreaterThan('openedAt', DateTime.now().add(Duration(days: -30)));
    queryBuilder.whereGreaterThan('createdAt', DateTime.now().add(Duration(hours: -2, minutes: -40)));
    queryBuilder.includeObject(['city', 'manager', 'customers']);

    var response = await queryBuilder.query();

@phillwiggins
Copy link
Member

phillwiggins commented Mar 18, 2019 via email

@danibjor
Copy link

@phillwiggins tested 5 minutes ago on v1.0.16 branch

@phillwiggins
Copy link
Member

Just testing this now and it seems like, greaterThan and lessThan return the same results. I'll correct and amend.

@RodrigoSMarques
Copy link
Contributor Author

@phillwiggins

this is related to the function _checkForMultipleColumnInstances

If it is the same field they must be grouped into a single condition.

For example: where = {"runCount": {"$ gt": "1", "$ lt": "500"}, "type": "D"}

This was working. It may have broken in this latest release.

@phillwiggins
Copy link
Member

That method was always working. There was only a small change you had added in your commit which is still there.

@RodrigoSMarques
Copy link
Contributor Author

So this is weird.
My change was because of DateTime. DateTime is a map and the function made a replaceAll of the character "}" and this caused error in the query. My change was to make sure the function only removes the last "}".

After upgrading my fork, I will redo all the tests.

@RodrigoSMarques
Copy link
Contributor Author

Resolved in branch v.1.0.16

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

No branches or pull requests

3 participants