firebase / firebase/firebase-ios-sdk

Firestore QuerySnapshot.documentChanges(includeMetadataChanges: false) always returns DocumentChange with only metadata changes

Open
#12,728 8 comments 0 reactions 1 assignee Claimed by @MarkDuckworth View on GitHub
api: firestore needs-attention
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 14h
Merged PRs (30d)
72

Description

### Description

In Firestore's `QuerySnapshot#documentChanges` API at https://github.com/firebase/firebase-ios-sdk/blob/03ce722d0e511a9f606ea95077d416aaaea4bdb6/Firestore/Source/Public/FirebaseFirestore/FIRQuerySnapshot.h#L68, it allows us to specify whether to include document changes with only metadata changes. However, from my observation, no matter this is set to true or false, it always returns document change even if there is only metadata change. This make it impossible for us to know which document change actually comes from the server.

I've tested the same piece of code in both Android and iOS. In Android, this behaviour works as expected, when I do `querySnapshot.getDocumentChanges(MetadataChanges.EXCLUDE)`, it will return 0 documentChange if there is only metadata changed.

### Reproducing the issue

For both Android and iOS, I'm using the exact same setup, listening to same collection with the same query, with `includeMetadataChanges` set to `true`.

Here's my code in iOS that processes the received `QuerySnapshot` and its log output when I write a new document locally:
![screenshot-20240409-162153](https://github.com/firebase/firebase-ios-sdk/assets/14089267/922068da-03eb-4843-84a9-27dae368068b)

![image](https://github.com/firebase/firebase-ios-sdk/assets/14089267/2e24c5d3-7fba-400d-9d64-deedbaa2a283)

Here's my code in Android that processes the received `QuerySnapshot` and its log output when I write a new document locally:
![screenshot-20240409-162132](https://github.com/firebase/firebase-ios-sdk/assets/14089267/52d3a2a6-0415-4d51-a181-03a8321dca4e)

![image](https://github.com/firebase/firebase-ios-sdk/assets/14089267/ae5cb634-5c9b-40d5-bd44-e91ed370a580)

### Firebase SDK Version

10.23.1

### Xcode Version

15.2

### Installation Method

Swift Package Manager

### Firebase Product(s)

Firestore

### Targeted Platforms

iOS

### Relevant Log Output

_No response_

### If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

```json

Replace this line with the contents of your Package.resolved.

```

### If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

```yml

Replace this line with the contents of your Podfile.lock!

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.