Skip to content

Commit eb4470a

Browse files
Review comments
1 parent 4f722ac commit eb4470a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/document.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ class DocumentMask {
11821182
applyTo(data) {
11831183
/*!
11841184
* Applies this DocumentMask to 'data' and computes the list of field paths
1185-
* that were specified in the mask but not present in 'data'.
1185+
* that were specified in the mask but are not present in 'data'.
11861186
*/
11871187
const applyDocumentMask = data => {
11881188
const remainingPaths = this._sortedPaths.slice(0);
@@ -1210,7 +1210,8 @@ class DocumentMask {
12101210
return result;
12111211
};
12121212

1213-
const filteredData = processObject(data);
1213+
// processObject() returns 'null' if the DocumentMask is empty.
1214+
const filteredData = processObject(data) || {};
12141215

12151216
return {
12161217
filteredData: filteredData,

test/document.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,15 @@ describe('set document', function() {
10381038
);
10391039
});
10401040

1041+
it('supports document merges with empty field mask', function() {
1042+
firestore.api.Firestore._commit = function(request, options, callback) {
1043+
requestEquals(request, set(document(), updateMask()));
1044+
callback(null, writeResult(1));
1045+
};
1046+
1047+
return firestore.doc('collectionId/documentId').set({}, {mergeFields: []});
1048+
});
1049+
10411050
it('supports document merges with field mask and empty maps', function() {
10421051
firestore.api.Firestore._commit = function(request, options, callback) {
10431052
requestEquals(

0 commit comments

Comments
 (0)