diff --git a/api/src/com/todoroo/andlib/data/AbstractModel.java b/api/src/com/todoroo/andlib/data/AbstractModel.java
index 6b770aea5..56bf3c5d1 100644
--- a/api/src/com/todoroo/andlib/data/AbstractModel.java
+++ b/api/src/com/todoroo/andlib/data/AbstractModel.java
@@ -11,6 +11,7 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.Map.Entry;
import java.util.Set;
import android.content.ContentValues;
@@ -21,6 +22,7 @@ import com.todoroo.andlib.data.Property.DoubleProperty;
import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.PropertyVisitor;
+import com.todoroo.andlib.utility.AndroidUtilities;
/**
* AbstractModel
represents a row in a database.
@@ -320,6 +322,20 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
setValues.putAll(other);
}
+ /**
+ * Merges set values with those coming from another source,
+ * keeping the existing value if one already exists
+ */
+ public synchronized void mergeWithoutReplacement(ContentValues other) {
+ if (setValues == null)
+ setValues = new ContentValues();
+ for (Entry item : other.valueSet()) {
+ if (setValues.containsKey(item.getKey()))
+ continue;
+ AndroidUtilities.putInto(setValues, item.getKey(), item.getValue(), true);
+ }
+ }
+
/**
* Clear the key for the given property
* @param property
diff --git a/astrid/src/com/todoroo/astrid/service/TaskService.java b/astrid/src/com/todoroo/astrid/service/TaskService.java
index 6a6389b28..bff5fb4f3 100644
--- a/astrid/src/com/todoroo/astrid/service/TaskService.java
+++ b/astrid/src/com/todoroo/astrid/service/TaskService.java
@@ -502,7 +502,7 @@ public class TaskService {
AndroidUtilities.putInto(forTask, key, value, true);
}
- task.mergeWith(forTask);
+ task.mergeWithoutReplacement(forTask);
}
if (task.getValue(Task.USER_ID) != Task.USER_ID_SELF)