Skip to content

Commit e3a55c5

Browse files
committed
Fix: set exists:false precondition for deleted docs.
1 parent 03a533e commit e3a55c5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/firestore/src/core/transaction.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,18 @@ export class Transaction {
142142

143143
/**
144144
* Returns the version of this document when it was read in this transaction,
145-
* as a precondition, or no precondition if it was not read.
145+
* as a precondition, or an existence precondition if the document did not
146+
* exist, or no precondition if it was not read.
146147
*/
147148
private precondition(key: DocumentKey): Precondition {
148149
const version = this.readVersions.get(key.toString());
149150
if (!this.writtenDocs.has(key.toString()) && version) {
150-
return Precondition.updateTime(version);
151+
if (version.isEqual(SnapshotVersion.min())) {
152+
// The document doesn't exist.
153+
return Precondition.exists(false);
154+
} else {
155+
return Precondition.updateTime(version);
156+
}
151157
} else {
152158
return Precondition.none();
153159
}

0 commit comments

Comments
 (0)