
Save returns false after assigning existing value to a lazy Text property
Reported by MarkMT | October 22nd, 2009 @ 11:21 AM
Given a model with lazy Text property, if an instance of the model is loaded (but with the Text property not loaded because of laziness), if you assign to the property the value already stored in the db, attempting to save the object will return false.
If there is one or more lazy Text properties in the model, assigning to any of them a value other than the original value will cause save to return true.
I have only tested/observed this issue with MySQL.
Comments and changes to this ticket
-
Angel N. Sciortino (angelic) October 22nd, 2009 @ 04:52 PM
I think this is because the database says 0 rows were affected if the data hasn't actually changed. Perhaps the unloaded field should be loaded and verified as being truly dirty before saving?
-
MarkMT October 22nd, 2009 @ 05:11 PM
I don't think that would explain why it only happens (apparently) with Text properties?
-
MarkMT October 24th, 2009 @ 08:42 AM
The problem is resolved when using dm-core/dm-more 0.10.2 and data_objects/do_mysql 0.10.1 from github.
-
Dan Kubb (dkubb) October 24th, 2009 @ 02:26 PM
- Assigned user set to Dan Kubb (dkubb)
- State changed from new to accepted
- Milestone set to 0.10.2
Angel is correct in that the reason for this problem is that since the attribute is lazy loaded, DM has no idea that the value is dirty or not. Without lazy loading the value (which is probably a waste) it has to assume the value is dirty and send it over.
In previous versions of DM, the number of affected rows would determine success of a save call or not. In DM 0.10.2 I decided that save should return true if the datastore state matches the state of the object.. so repeated calls to save the same data should always return true. I think it's important that saving a Resource be idempotent.
I am going to keep this ticket open to verify that there are specs covering this specific behavior so that it remains a part of the API.
-
Dan Kubb (dkubb) February 1st, 2010 @ 04:33 PM
- Milestone changed from 0.10.2 to 1.0.0
-
-
-
Dan Kubb (dkubb) February 2nd, 2010 @ 02:47 AM
- State changed from accepted to confirmed
-
Dan Kubb (dkubb) May 26th, 2010 @ 02:11 AM
- Milestone set to 1.0.0
- Assigned user set to Dan Kubb (dkubb)
-
Dan Kubb (dkubb) June 2nd, 2010 @ 02:16 PM
- Milestone cleared.
- Assigned user cleared.
Pushing this to after the 1.0 release since it isn't something that will change the public API.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »