-
Notifications
You must be signed in to change notification settings - Fork 666
Adding FieldValue.numericAdd() #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
20152fe
602d03f
ef1862b
6e386c4
0df4ee8
e74e03c
1f98e0a
720d708
2a4807f
3bd91ec
f4cf039
3f2e09e
261c7c8
bb10ecb
5b4f0a2
29758d1
991fb7c
94493b8
468c282
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,10 @@ public MaybeDocument applyToLocalView( | |
|
|
||
| @Override | ||
| public FieldMask getFieldMask() { | ||
| // Note: Theoretically, we should only include non-idempotent fields in this field mask as this | ||
| // mask is used to populate the base state for all DocumentTransforms. By including all | ||
| // fields, we incorrectly prevent rebasing of idempotent transforms (such as `arrayUnion()`) | ||
| // when any non-idempotent transforms are present. | ||
|
||
| List<FieldPath> fieldMask = new ArrayList<>(); | ||
| for (FieldTransform transform : fieldTransforms) { | ||
| fieldMask.add(transform.getFieldPath()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -968,6 +968,9 @@ public void testHandlesSetMutationThenTransformMutationThenTransformMutation() { | |
| @Test | ||
| public void testHandlesSetMutationThenAckThenTransformMutationThenAckThenTransformMutation() { | ||
mikelehen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (garbageCollectorIsEager()) { | ||
mikelehen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Since this test doesn't open a Query, Eager GC removes the documents from the cache as soon | ||
|
||
| // as the mutation is applied. This creates a lot of special casing in this unit test but does | ||
| // not expand its test coverage. | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -1088,4 +1091,22 @@ public void testHandlesSetMutationThenTransformMutationThenRemoteEventThenTransf | |
| assertChanged(doc("foo/bar", 4, map("sum", 1339), Document.DocumentState.COMMITTED_MUTATIONS)); | ||
| assertContains(doc("foo/bar", 4, map("sum", 1339), Document.DocumentState.COMMITTED_MUTATIONS)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testHandlesMergeMutationThenRemoteEvent() { | ||
| Query query = Query.atPath(ResourcePath.fromString("foo")); | ||
| allocateQuery(query); | ||
| assertTargetId(2); | ||
|
|
||
| writeMutations( | ||
| asList( | ||
| patchMutation("foo/bar", map(), Collections.emptyList()), | ||
| transformMutation("foo/bar", map("sum", FieldValue.numericAdd(1))))); | ||
| assertChanged(doc("foo/bar", 0, map("sum", 1), Document.DocumentState.LOCAL_MUTATIONS)); | ||
| assertContains(doc("foo/bar", 0, map("sum", 1), Document.DocumentState.LOCAL_MUTATIONS)); | ||
|
|
||
| applyRemoteEvent(addedRemoteEvent(doc("foo/bar", 1, map("sum", 1337)), asList(2), emptyList())); | ||
| assertChanged(doc("foo/bar", 1, map("sum", 1), Document.DocumentState.LOCAL_MUTATIONS)); | ||
| assertContains(doc("foo/bar", 1, map("sum", 1), Document.DocumentState.LOCAL_MUTATIONS)); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.