Skip to content

Commit

Permalink
fix: Allow an explicit MustExist precondition for update (#1542)
Browse files Browse the repository at this point in the history
  • Loading branch information
dconeybe committed Jan 24, 2024
1 parent ead5e14 commit 46e09aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion google-cloud-firestore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-conformance-tests</artifactId>
<version>0.3.6</version>
<version>0.3.7</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ boolean isEmpty() {
return exists == null && updateTime == null;
}

boolean hasExists() {
return exists != null;
Boolean getExists() {
return exists;
}

com.google.firestore.v1.Precondition toPb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ public T update(
@Nonnull Map<String, Object> fields,
Precondition precondition) {
Preconditions.checkArgument(
!precondition.hasExists(), "Precondition 'exists' cannot be specified for update() calls.");
!Boolean.FALSE.equals(precondition.getExists()),
"Precondition 'exists' cannot have the value 'false' for update() calls.");
return performUpdate(
documentReference, convertToFieldPaths(fields, /* splitOnDots= */ true), precondition);
}
Expand Down Expand Up @@ -455,7 +456,8 @@ public T update(
@Nullable Object value,
Object... moreFieldsAndValues) {
Preconditions.checkArgument(
!precondition.hasExists(), "Precondition 'exists' cannot be specified for update() calls.");
!Boolean.FALSE.equals(precondition.getExists()),
"Precondition 'exists' cannot have the value 'false' for update() calls.");
return performUpdate(
documentReference,
precondition,
Expand Down Expand Up @@ -483,7 +485,8 @@ public T update(
@Nullable Object value,
Object... moreFieldsAndValues) {
Preconditions.checkArgument(
!precondition.hasExists(), "Precondition 'exists' cannot be specified for update() calls.");
!Boolean.FALSE.equals(precondition.getExists()),
"Precondition 'exists' cannot have the value 'false' for update() calls.");
return performUpdate(documentReference, precondition, fieldPath, value, moreFieldsAndValues);
}

Expand Down

0 comments on commit 46e09aa

Please sign in to comment.