File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
Example/Tests/Integration Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
+ - [ changed] ` Transaction.getDocument() ` has been changed to return a non-nil
3
+ ` DocumentSnapshot ` with ` exists ` equal to ` false ` if the document does not
4
+ exist (instead of returning a nil DocumentSnapshot). Code that was previously
5
+ doing ` if (snapshot) { ... } ` must be changed to
6
+ ` if (snapshot.exists) { ... } ` .
2
7
3
8
# v0.16.1
4
9
- [ fixed] Offline persistence now properly records schema downgrades. This is a
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ - (void)testGetNonexistentDocumentThenCreate {
81
81
runTransactionWithBlock: ^id _Nullable (FIRTransaction *transaction, NSError **error) {
82
82
FIRDocumentSnapshot *snapshot = [transaction getDocument: doc error: error];
83
83
XCTAssertNil (*error);
84
+ XCTAssertNotNil (snapshot);
84
85
XCTAssertFalse (snapshot.exists );
85
86
[transaction setData: @{@" foo" : @" bar" } forDocument: doc];
86
87
return @YES ;
Original file line number Diff line number Diff line change @@ -119,16 +119,22 @@ - (void)getDocument:(FIRDocumentReference *)document
119
119
HARD_ASSERT (documents.count == 1 ,
120
120
" Mismatch in docs returned from document lookup." );
121
121
FSTMaybeDocument *internalDoc = documents.firstObject ;
122
- if ([internalDoc isKindOfClass: [FSTDocument class ]]) {
122
+ if ([internalDoc isKindOfClass: [FSTDeletedDocument class ]]) {
123
+ FIRDocumentSnapshot *doc =
124
+ [FIRDocumentSnapshot snapshotWithFirestore: self .firestore
125
+ documentKey: document.key
126
+ document: nil
127
+ fromCache: NO
128
+ hasPendingWrites: NO ];
129
+ completion (doc, nil );
130
+ } else if ([internalDoc isKindOfClass: [FSTDocument class ]]) {
123
131
FIRDocumentSnapshot *doc =
124
132
[FIRDocumentSnapshot snapshotWithFirestore: self .firestore
125
133
documentKey: internalDoc.key
126
134
document: (FSTDocument *)internalDoc
127
135
fromCache: NO
128
136
hasPendingWrites: NO ];
129
137
completion (doc, nil );
130
- } else if ([internalDoc isKindOfClass: [FSTDeletedDocument class ]]) {
131
- completion (nil , nil );
132
138
} else {
133
139
HARD_FAIL (" BatchGetDocumentsRequest returned unexpected document type: %s" ,
134
140
NSStringFromClass ([internalDoc class ]));
You can’t perform that action at this time.
0 commit comments