Skip to content

Commit f662d48

Browse files
Checking for UnknownDocument
1 parent 411c4bd commit f662d48

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

packages/firestore/src/api/database.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,11 @@ export class Transaction implements firestore.Transaction {
597597
} else if (doc instanceof Document) {
598598
return new DocumentSnapshot(this._firestore, ref._key, doc, false);
599599
} else {
600-
throw fail('MaybeDocument is neither Document nor NoDocument');
600+
throw fail(
601+
`BatchGetDocumentsRequest returned unexpected document type: ${
602+
doc.constructor.name
603+
}`
604+
);
601605
}
602606
});
603607
}

packages/firestore/src/local/local_documents_view.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,10 @@ export class LocalDocumentsView {
168168
baseDoc,
169169
batch.localWriteTime
170170
);
171-
if (!mutatedDoc || mutatedDoc instanceof NoDocument) {
172-
results = results.remove(key);
173-
} else if (mutatedDoc instanceof Document) {
171+
if (mutatedDoc instanceof Document) {
174172
results = results.insert(key, mutatedDoc);
175173
} else {
176-
fail('Unknown MaybeDocument: ' + mutatedDoc);
174+
results = results.remove(key);
177175
}
178176
}
179177
}

packages/firestore/src/model/mutation.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,7 @@ export class Precondition {
156156
maybeDoc.version.isEqual(this.updateTime)
157157
);
158158
} else if (this.exists !== undefined) {
159-
if (this.exists) {
160-
return maybeDoc instanceof Document;
161-
} else {
162-
return maybeDoc === null || maybeDoc instanceof NoDocument;
163-
}
159+
return this.exists === maybeDoc instanceof Document;
164160
} else {
165161
assert(this.isNone, 'Precondition should be empty');
166162
return true;

0 commit comments

Comments
 (0)