Open snej opened 8 years ago
It might also be a good idea to add a validation function. Because even if the bug is fixed locally, if an earlier version of the app puts an invalid document in the database it'll get pushed to the server and then replicated to other clients that will then barf on it. A validation function would block it from being received by the other clients. (I had to do this to Grocery Sync a long time ago in response to an old version of the Android version of the app storing dates in an invalid format.)
It's possible for ToDoLite to create invalid documents with a
type
property but no other properties. These then trigger exceptions in the view map functions, which use properties likelist_id
that shouldn't be nil. (See couchbase/couchbase-lite-ios#1071).The bug is in Titled.m:
The steps that trigger the bug:
[Task modelForDocument: doc]
to instantiate a new Task object. When the Task awakes itstype
andcreated_at
get set, but no other properties.list_id
.I'm not sure how step 1 happened, but the rest is pretty clear. The fix is to take out this method and set the
type
andcreated_at
only when explicitly creating a new model.