-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Models that fail a save to the DB still save to the cache #78
Comments
This is somewhat the expected behaviour, I'm not sure the best strategy to avoid this. If you do this on the second Project.get(1, function(err, project){
console.log(project.saved()); // false
}); Perhaps I can force the Singleton object to fetch from database when cached instance is not saved. What do you think? This made me think that an |
What do you think? If you use the last git version your problem should be solved. Still, for people wanting the old behaviour, it's just a setting away. var orm = require("orm");
orm.settings.set("instance.cacheSaveCheck", false); // true by default |
Looks good to me. Let me see if I understand. You enabled cacheSaveCheck to be true by default, and now saving to cache will check to see if it was saved to the cache first? |
I created cacheSaveCheck that if enabled (default) will not return an instance from cache if it's not saved. So if you fetch A, change it, and then fetch again, the cache will see that what it has is not saved and so will fetch it again. |
I'll assume this now behaves as you expected. If not please reopen and explain :) |
Hi, I'm not sure if this is by design or not, but I noticed if a model fails validation during save, it is still saved to the cache. I'm using postgres.
Model definition
Save an invalid value to the model.
Later, retrieving the model will print the invalid value.
The text was updated successfully, but these errors were encountered: