Fix duplicate results on live query when in TX with multiple save() operations
@@ -248,9 +248,20 @@ public class OLiveQueryHookV2 extends ODocumentHookAbstract implements ODatabase
list = new ArrayList<OLiveQueryOp>();
ops.pendingOps.put(db, list);
}
+ if (result.type != ORecordOperation.UPDATED || !alreadyRegisteredAsUpdate(list, result.originalDoc)) {
list.add(result);
}
}
+ }
+
+ private boolean alreadyRegisteredAsUpdate(List<OLiveQueryOp> list, ODocument doc) {
+ for (OLiveQueryOp oLiveQueryOp : list) {
+ if (oLiveQueryOp.originalDoc == doc) {
+ return true;
+ }
+ }
+ return false;
+ }
private OResultInternal calculateBefore(ODocument iDocument) {
OResultInternal result = calculateAfter(iDocument);
