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

containedIn does not work with LiveQuery #296

Closed
4 tasks done
davidhakki opened this issue Dec 8, 2021 · 10 comments
Closed
4 tasks done

containedIn does not work with LiveQuery #296

davidhakki opened this issue Dec 8, 2021 · 10 comments
Labels
type:question Support or code-level question

Comments

@davidhakki
Copy link

New Issue Checklist

Issue Description

containedIn query does not update LiveQuery

Steps to reproduce

Subscribe to a LiveQuery with a containedIn, will not update such as:
query = query.where(containedIn(key: "parties", array: [usersProfile.id]))

But a normal equals query seems to update perfectly:
query = query.where("senderID" == "VcF9fMCyKb")

Actual Outcome

Nothing, it will not update at all. Note the query containedIn loads perfectly fine when using fetch or even using the subscribedQuery but will not activate any of the events.

Environment

Client

  • Parse Swift SDK version: 2.3.1
  • Xcode version: 13.1
  • Operating system (iOS, macOS, watchOS, etc.): macOS
  • Operating system version: 12.0.1

Server

  • Parse Server version: 4.4.0
  • Operating system: No idea
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Back4App

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 3.6
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): Back4App

Logs

When using containedIn
Successfully subscribed to new query Message ({"limit":100,"skip":0,"_method":"GET","where":{"parties":{"$in":["CwyLdNXNAH"]}}}) Saved Message

When using equals to (as you can see it updates both new messages and editing old ones)

Successfully subscribed to new query Message ({"limit":100,"skip":0,"_method":"GET","where":{"senderID":"VcF9fMCyKb"}})
Saved Message
Optional([Message ({"spouseID":"CwyLdNXNAH","time":{"__type":"Date","iso":"2021-12-07T23:09:16.057Z"},"senderID":"VcF9fMCyKb","read":true,"text":"Nice","objectId":"O0rkPsUIVw","updatedAt":{"__type":"Date","iso":"2021-12-07T23:26:08.452Z"},"createdAt":{"__type":"Date","iso":"2021-12-07T23:09:16.127Z"},"parties":["VcF9fMCyKb","CwyLdNXNAH"]}), Message ({"spouseID":"CwyLdNXNAH","time":{"__type":"Date","iso":"2021-12-08T00:15:56.536Z"},"senderID":"VcF9fMCyKb","read":true,"text":"Ok wow","objectId":"KBz1yl6SHs","updatedAt":{"__type":"Date","iso":"2021-12-08T00:34:56.260Z"},"createdAt":{"__type":"Date","iso":"2021-12-08T00:15:56.639Z"},"parties":["VcF9fMCyKb","CwyLdNXNAH"]})])
Updated: Message ({"spouseID":"CwyLdNXNAH","time":{"__type":"Date","iso":"2021-12-08T00:15:56.536Z"},"senderID":"VcF9fMCyKb","read":true,"text":"Ok wow","objectId":"KBz1yl6SHs","updatedAt":{"__type":"Date","iso":"2021-12-08T00:34:56.260Z"},"createdAt":{"__type":"Date","iso":"2021-12-08T00:15:56.639Z"},"parties":["VcF9fMCyKb","CwyLdNXNAH"]})
Updated: Message ({"spouseID":"CwyLdNXNAH","time":{"__type":"Date","iso":"2021-12-07T23:09:16.057Z"},"senderID":"VcF9fMCyKb","read":true,"text":"Nice too","objectId":"O0rkPsUIVw","updatedAt":{"__type":"Date","iso":"2021-12-08T00:35:07.796Z"},"createdAt":{"__type":"Date","iso":"2021-12-07T23:09:16.127Z"},"parties":["VcF9fMCyKb","CwyLdNXNAH"]})
Entered: Message ({"spouseID":"VcF9fMCyKb","time":{"__type":"Date","iso":"2021-12-07T23:26:20.541Z"},"senderID":"VcF9fMCyKb","read":true,"text":"Cool","objectId":"gJCz7b6cIW","updatedAt":{"__type":"Date","iso":"2021-12-08T00:36:17.128Z"},"createdAt":{"__type":"Date","iso":"2021-12-07T23:26:20.635Z"},"parties":["CwyLdNXNAH","VcF9fMCyKb"]})
@parse-github-assistant
Copy link

Thanks for opening this issue!

  • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.

@cbaker6 cbaker6 added the type:question Support or code-level question label Dec 8, 2021
@cbaker6
Copy link
Contributor

cbaker6 commented Dec 8, 2021

LiveQuery doesn't support every type of query. You can see one of the newer PR's on the server that added more constraints, parse-community/parse-server#7113 and check here for all current, https://github.com/parse-community/parse-server/blob/alpha/spec/QueryTools.spec.js. If you find something missing that you think should be added on the server, I suggest opening an issue there with a possible PR to fix. You may also want open an issue for the live query server to throw an error if a query isn’t supported. More info can be found in the LiveQuery Spec, https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification#subscribe-message

From your log:

Successfully subscribed to new query Message ({"limit":100,"skip":0,"_method":"GET","where":{"parties":{"$in":["CwyLdNXNAH"]}}}) Saved Message

The Swift SDK passes containedIn to the server correctly, meaning once the server supports this type of query it will automatically trigger events (the Swift SDK already supports this query, but the server doesn’t).

If you find containedIn not working for a regular query, your issue should then be in this repo.

@cbaker6 cbaker6 added state:wont-fix Won’t be fixed with a clearly stated reason and removed state:wont-fix Won’t be fixed with a clearly stated reason labels Dec 8, 2021
@lsmilek1
Copy link
Contributor

lsmilek1 commented Dec 9, 2021

Pardon additional question... Is this issue about updating the query after it is subscribed for the first time? Because I am actually using "containedIn" as per command above and it is working. I just have to unsubscribe it and subscribe again whenever I need to change the array of the criteria

@davidhakki
Copy link
Author

Pardon additional question... Is this issue about updating the query after it is subscribed for the first time? Because I am actually using "containedIn" as per command above and it is working. I just have to unsubscribe it and subscribe again whenever I need to change the array of the criteria

No unfortunately despite the subscription I would get zero updates/deletions etc. What version of parse server are you on?

@cbaker6
Copy link
Contributor

cbaker6 commented Dec 10, 2021

@EliteTechnicalCare you should provide more information in your question. For example, show all of your complete ParseObject's in question.

I suspect the parties field is actually of type "pointer", if so, your query isn't correct.

Also, you should check if your regular containedIn query works before trying it with LiveQuery. The examples you showed are completely different from each other and aren't checking the same property:

query = query.where(containedIn(key: "parties", array: [usersProfile.id]))
query = query.where("senderID" == "VcF9fMCyKb")

For questions, you should ask here: https://community.parseplatform.org

as oppose to opening issues.

@cbaker6 cbaker6 closed this as completed Dec 10, 2021
@davidhakki
Copy link
Author

davidhakki commented Dec 10, 2021

@EliteTechnicalCare you should provide more information in your question. For example, show all of your complete ParseObject's in question.

I suspect the parties field is actually of type "pointer", if so, your query isn't correct.

parties is an Array not a pointer.

Also, you should check if your regular containedIn query works before trying it with LiveQuery. The examples you showed are completely different from each other and aren't checking the same property:

query = query.where(containedIn(key: "parties", array: [usersProfile.id]))
query = query.where("senderID" == "VcF9fMCyKb")

As I specified in my original post, the query works perfectly fine, it simply doesn't auto update after the initial fetch.

For questions, you should ask here: https://community.parseplatform.org

as oppose to opening issues.

What question have I asked this entire thread?

@cbaker6
Copy link
Contributor

cbaker6 commented Dec 10, 2021

Your original post and everything after doesn’t signal there’s an actual issue. You haven’t provided enough information to elude to an issue or even replicate an issue. It seems, from your post, you are probably not setting up your queries correctly which is why this is labeled as a question. If your ask the question, “how to properly setup a live query using containedIn?” on the link I provided and provide the details of your ParseObjects and queries, you will most likely get what you need. If there happens to be a bug with correct setup, then you should open an issue.

As I specified in my original post, the query works perfectly fine, it simply doesn't auto update after the initial fetch.

Your original post looks sketchy and doesn't provide enough info as I mentioned here. Your post is better suited as a question until we can see you are querying correctly and there's in fact a real bug.

@davidhakki
Copy link
Author

you are probably not setting up your queries correctly

Which is why it works perfectly fine until I attempt a LiveQuery with it. I haven't asked a question, I understand how queries work. They are working perfectly fine, the only issue is when I use a query with containedIn with LiveQuery. Every other query ive tested works fine with LiveQuery. So I know how to use LiveQuery. Every time Ive used containedIn for normal queries works fine. So I know how to use containedIn. Only issue I am having is when I am using containedIn with LiveQuery.

@lsmilek1 says it works with him so the only thing I asked him was what server version he is running. I am not denying that this could very well be a server issue, but I am not here for a tutorial on how to do queries. Rather, I am trying to pin point where the issue is and report it (if need be).

I am not trying to be difficult, I have left this issue closed etc but would be good to see what server version he is running so I can move forward in the right direction.

@cbaker6
Copy link
Contributor

cbaker6 commented Dec 10, 2021

Every time Ive used containedIn for normal queries works fine. So I know how to use containedIn. Only issue I am having is when I am using containedIn with LiveQuery.

I stated here, you provided examples that are "completely different" from each other, essentially you provided an apples to oranges comparison.

Proper steps to flush out where your problem is:

  1. create a simple == query, find the results, are they correct?
  2. use the query in "1" as a live query, do you receive the proper updates?
  3. create a simple containedIn query, find the results, are they correct? (you have not provided anything that shows you have done this the entire thread, thus making it extremely hard to help you)
  4. use the query in "3" as a live query, do you receive the proper updates?

If 1,2, and 3 works and 4 doesn't, then either:

  1. LiveQuery doesn't support containedIn, or
  2. LiveQuery doesn't support containedIn in the version of the server you are using and may support it in a newer version

If 1 and 2 work, and 3 and 4 doesn't work then either:

  1. you have setup your containedIn query incorrectly
  2. there's a bug in the Swift SDK (less likely, but possible as the SDK has test cases. In addition @lsmilek1 mentioned it worked https://community.parseplatform.org/t/update-constraint-of-livequery/1866
  3. there's a bug on the server (even less likely as the server has test cases and other SDKs use this)

In any of the cases, you should be providing enough information when asking a question or opening an issue. Enough information requires providing your ParseObject's to understand your setup. In addition, you should take the debugging steps necessary to isolate your problem (1-4 above) and show the results of these steps.

@cbaker6
Copy link
Contributor

cbaker6 commented Dec 10, 2021

parties is an Array not a pointer.

parties is an array of what exactly? Your query attempts to treat it as an "array of strings", particularly containing objectId's. I ask if this is an array of "pointers" to ParseObject's because if it is, your query is incorrect. If you provided your ParseObject or what this field looks like in your Parse Dashboard, then this type of question wouldn't need to be asked

As I specified in my original post, the query works perfectly fine, it simply doesn't auto update after the initial fetch.

We will need you to provide necessary information I asked for in the previous comments to determine if it's indeed "perfectly fine."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

3 participants