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

cloud_firestore needs metadata for QuerySnapshot (in addition to DocumentSnapshots in it) #35550

Closed
gazialankus opened this issue Jul 3, 2019 · 3 comments · Fixed by flutter/plugins#1915
Assignees

Comments

@gazialankus
Copy link
Contributor

gazialankus commented Jul 3, 2019

metadata in QuerySnapshot is an existing Firestore feature in other platforms but it's not there in Flutter.

The Flutter cloud_firestore library's QuerySnapshot object needs to provide a metadata field that indicates whether the query result is coming from the cache or the server. The individual DocumentSnapshot objects in QuerySnapshot have this metadata field; however, when the query result is empty, we don't get any DocumentSnapshot objects and we have no idea whether the QuerySnapshot came from the cache (offline) or from the server.

Android and Web already have metadata in QuerySnapshot. I didn't check other platforms.

I was hoping I could fix it myself and provide a PR, however it seems we just don't get that data under the hood. When I set a breakpoint here, I see that data, which is the result of Query#getDocuments has only these fields:

0 = {map entry} "documentChanges" -> [_List]
1 = {map entry} "documents" -> [_List]
2 = {map entry} "metadatas" -> [_List]
3 = {map entry} "paths" -> [_List]

The metadatas field is related to the individual DocumentSnapshots. When the query result is empty, all of these lists are empty as well. Hence the lack of metadata about our query.

It seems this is coming from a platform channel, so definitely it must be using Android Firebase libraries. However, as I said above, Android libraries have metadata for QuerySnapshot but Flutter, which seems to be using the Android libraries through a platform channel does not have it. Is this because the Flutter plugin is using an old version of the Android library?

The current way to add Firebase to Flutter does not have anything about Android Firebase library versions. Only classpath 'com.google.gms:google-services:3.2.1' seems to be a versioned thing, is it what's holding this back? I tried 4.2.0 but it's the same.

Here is a relevant discussion in Slack. I'd appreciate any suggestion.

@katowulf
Copy link

katowulf commented Jul 3, 2019

@kroikie fyi

@kroikie kroikie self-assigned this Jul 20, 2019
@kroikie
Copy link

kroikie commented Jul 25, 2019

Looks like when parsing the QuerySnapshot the metadata of the QuerySnapshot is not included in the data that is passed back to the Dart side. I don't see any reason we could not add a field for this.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants