Skip to content

Commit 2f76a53

Browse files
---
yaml --- r: 8753 b: refs/heads/master c: 112b25c h: refs/heads/master i: 8751: 80cf204
1 parent d2e8444 commit 2f76a53

4 files changed

Lines changed: 7 additions & 22 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3ea00d190a232274e2f6538b48b2df411642ec16
2+
refs/heads/master: 112b25c6d0c0f77e2e5961a9d2fe3fa042d010dc
33
refs/heads/travis: 47e4fee4fd5af9b2a8ce46f23c72ec95f9b195b2
44
refs/heads/gh-pages: 6daca92127d91b7c2c99490080ecf8a13fa94cde
55
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

trunk/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UpdateBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ private T performSet(
245245
DocumentTransform.fromFieldPathMap(documentReference, documentData);
246246

247247
if (options.isMerge()) {
248+
Preconditions.checkArgument(!fields.isEmpty(), "Data to merge cannot be empty.");
248249
if (options.getFieldMask() != null) {
249250
List<FieldPath> fieldMask = new ArrayList<>(options.getFieldMask());
250251
fieldMask.removeAll(documentTransform.getFields());
@@ -256,12 +257,11 @@ private T performSet(
256257

257258
Mutation mutation = addMutation();
258259

259-
boolean hasDocumentData = !documentSnapshot.isEmpty() || !documentMask.isEmpty();
260-
261-
if (!options.isMerge()) {
262-
mutation.document = documentSnapshot.toPb();
263-
} else if (hasDocumentData || documentTransform.isEmpty()) {
260+
if (!options.isMerge() || !documentSnapshot.isEmpty() || !documentMask.isEmpty()) {
264261
mutation.document = documentSnapshot.toPb();
262+
}
263+
264+
if (!documentMask.isEmpty()) {
265265
mutation.document.setUpdateMask(documentMask.toPb());
266266
}
267267

trunk/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ public class ConformanceTest {
8585
private interface ConformanceTestCase extends Test, Describable {}
8686

8787
/** Excluded tests by test description. */
88-
private final Set<String> excludedTests =
89-
Collections.singleton("set: MergeAll cannot be specified with empty data."); // b/73495873
88+
private final Set<String> excludedTests = Collections.emptySet();
9089

9190
/** If non-empty, only runs tests included in this set. */
9291
private final Set<String> includedTests = Collections.emptySet();

trunk/google-cloud-firestore/src/test/java/com/google/cloud/firestore/DocumentReferenceTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -411,20 +411,6 @@ public void setDocumentWithMerge() throws Exception {
411411
}
412412
}
413413

414-
@Test
415-
public void setDocumentWithEmptyMerge() throws Exception {
416-
doReturn(SINGLE_WRITE_COMMIT_RESPONSE)
417-
.when(firestoreMock)
418-
.sendRequest(
419-
commitCapture.capture(), Matchers.<UnaryCallable<CommitRequest, CommitResponse>>any());
420-
421-
documentReference.set(map(), SetOptions.merge()).get();
422-
423-
assertCommitEquals(
424-
commit(set(Collections.<String, Value>emptyMap(), Collections.<String>emptyList())),
425-
commitCapture.getValue());
426-
}
427-
428414
@Test
429415
public void setDocumentWithNestedMerge() throws Exception {
430416
doReturn(SINGLE_WRITE_COMMIT_RESPONSE)

0 commit comments

Comments
 (0)