couchbaselabs / CouchCocoa

Objective-C API for CouchDB on iOS and Mac OS
http://couchbaselabs.github.com/CouchCocoa/docs/
218 stars 66 forks source link

Don't try to decode the old NSData or NSDate values when the property has been set to nil #73

Closed martijnwalraven closed 11 years ago

martijnwalraven commented 11 years ago

After setting an existing data or date property to nil on a CouchModel, attempts to get the value continue to use the decoded raw value. It turns out cacheValue:ofProperty:changed: removes the value from the _properties dictionary, but getDataProperty: and getDateProperty: will try to decode the old raw value again if the property value is nil. In getValueOfProperty: there is an extra check to see if the model is new or if the property has been changed. Putting the same checks in getDataProperty: and getDateProperty: seems to solve the problem.

snej commented 11 years ago

Looks like a good fix; thanks. I'm applying the same fix to Couchbase Lite (commit de6199aed7c5c529207525d4b89e09159434f5fe).