Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

QueryBuilder with a ParseObject encode to json not correct. #138

Closed
zakiso opened this issue Mar 24, 2019 · 11 comments
Closed

QueryBuilder with a ParseObject encode to json not correct. #138

zakiso opened this issue Mar 24, 2019 · 11 comments

Comments

@zakiso
Copy link

zakiso commented Mar 24, 2019

When I use queryBuilder build a query and query condition contains a ParseObject then the server response a error. The error is Unexpected token _ in JSON at position.

This is my code:

///build a query
var queryBuilder = QueryBuilder<ParseObject>(ParseObject("Note"));
var book = ParseObject("Book");
....
///other query limit
....
queryBuilder.whereEqualTo(
            "book",book);

My console out put:

....
....
where={"updatedAt":{ "$gt":{"__type":"Date","iso":"2019-03-23T16:00:00.000Z"}, "$lt":{"__type":"Date","iso":"2019-03-24T15:59:59.000Z"}},"book": {__type: Pointer, className: Books, objectId: HZ09pN5NXI}}&skip=0
@phillwiggins
Copy link
Member

phillwiggins commented Mar 24, 2019 via email

@zakiso
Copy link
Author

zakiso commented Mar 24, 2019

Sorry for my poor english.
When my query condition contains a parseObject object, the server cannot parse the data correctly.
The Book object should be wrapped in quotes.

@phillwiggins
Copy link
Member

Oh right, so none of the elements in the books JSON object are wrapped in quotation marks?

@zakiso
Copy link
Author

zakiso commented Mar 24, 2019

Yes

@phillwiggins
Copy link
Member

Very strange.

What's happens if you create an instance of a Note object and call .toPointer in the whereEqualTo call?

@zakiso
Copy link
Author

zakiso commented Mar 24, 2019

Oh strange.
Everything works fine when I manually call toPointer.This my console output:

where={"updatedAt":{ "$gt":{"__type":"Date","iso":"2019-03-23T16:00:00.000Z"}, "$lt":{"__type":"Date","iso":"2019-03-24T15:59:59.000Z"}},"book": {"__type":"Pointer","className":"Books","objectId":"HZ09pN5NXI"}}&skip=0

my code:

...
queryBuilder.whereEqualTo(
            "book",book.toPointer());
...

@phillwiggins
Copy link
Member

phillwiggins commented Mar 24, 2019 via email

@zakiso
Copy link
Author

zakiso commented Mar 24, 2019

But when I manually call toPointer, the parse server will not response an error.

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Mar 24, 2019

@zakiso
Which version are you using? Show your pubscpec.yaml.

The problem with pointers has been resolved.

The correct it use:

queryBuilder.whereEqualTo("field", Object.toPointer());

@zakiso
Copy link
Author

zakiso commented Mar 25, 2019

@RodrigoSMarques
Everything works fine when I use this method that your provided.
queryBuilder.whereEqualTo("field", Object.toPointer());

@RodrigoSMarques
Copy link
Contributor

@phillwiggins
Close this issue to keep open only what is in trouble.
Resolved according to the above comment

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants