Skip to content
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

fix: Allow an explicit MustExist precondition for update #1542

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading