Skip to content
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 with _auto_sync are not saved on instantiation #380

Closed
andrewthetechie opened this issue Dec 14, 2022 · 7 comments
Closed

Models with _auto_sync are not saved on instantiation #380

andrewthetechie opened this issue Dec 14, 2022 · 7 comments

Comments

@andrewthetechie
Copy link
Owner

Describe the bug
Originally reported by @david-whalstedt in #379

Furthermore I have noticed that if you create an instance with _auto_sync on (default), it is not saved in Redis until you assign some field to it after creation. I

To Reproduce
Steps to reproduce the behavior:

  1. Create a model and make sure _auto_sync is true
  2. Instantiate an instance of the model
  3. Confirm it is not saved to Redis
@andrewthetechie andrewthetechie added the bug Something isn't working label Dec 14, 2022
@andrewthetechie andrewthetechie changed the title Modiles with _auto_sync are not saved on instantiation Models with _auto_sync are not saved on instantiation Dec 14, 2022
@andrewthetechie andrewthetechie removed the bug Something isn't working label Dec 14, 2022
@andrewthetechie
Copy link
Owner Author

This is an expected outcome with how the code currently works

_auto_sync is expected to sync changes to a model that has already been saved to Redis. For example, if you retrieve a model from Redis and update one of its fields, then _auto_sync will save that field change into Redis.

Perhaps a new _auto_save option could be used to save a model on instantiation if that's the desired behavior.

@andrewthetechie
Copy link
Owner Author

Docs could also be improved to make it clear how _auto_sync works

@david-wahlstedt
Copy link

In those cases we have chosen _auto_sync to be on, don't we always want to have it in Redis when created? Can you give an example of when it wouldn't be preferable?

andrewthetechie added a commit that referenced this issue Dec 17, 2022
This commit addresses feedback received in #380
about how the auto_sync feature works on models.
@andrewthetechie
Copy link
Owner Author

Here is what I'm thinking as a fix for your request @david-wahlstedt #396

I'm open to feedback if this doesn't work for you.

@david-wahlstedt
Copy link

david-wahlstedt commented Dec 19, 2022 via email

@andrewthetechie
Copy link
Owner Author

Thanks for checking it out! I appreciate your feedback.

No worries on response time, you're plenty fast!

@andrewthetechie
Copy link
Owner Author

Closed my previous PR and refactored as #401

This adds a new parameter to models, _auto_save, that will save a model to Redis on instantiation. It also adds documentation on how to use _auto_save, _auto_sync, and the new update()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants