Skip to content

Commit e624789

Browse files
author
Brian Chen
committed
Iterate through all elements of target array for ArrayRemove
1 parent 35f3ac3 commit e624789

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Firestore/core/src/model/transform_operation.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,12 @@ FieldValue ArrayTransform::Rep::Apply(
251251
}
252252
} else {
253253
HARD_ASSERT(type_ == Type::ArrayRemove);
254-
if (pos != result.end()) {
255-
result.erase(pos);
254+
for (int i = 0; i < static_cast<int>(result.size());) {
255+
if (type_ == Type::ArrayRemove && element == result.at(i)) {
256+
result.erase(result.cbegin() + i);
257+
} else {
258+
++i;
259+
}
256260
}
257261
}
258262
}

0 commit comments

Comments
 (0)