Add option to control auto refresh after save #2070
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
Add option to control auto refresh after save.
Motivation
The newly introduced "auto refresh" functionality does not work properly in all cases yet and a part from that it might still be situations where you don't want/need to run the extra select query.
Proposed solution
Added the autoRefresh option to the save method to control weather or not auto refresh the model after save. Defaulted to true to not break the current behavior and also made it affect databases that supports the RETURNING statement for completeness. Of course there might not be many real life cases where you would turn it off for those.
Current PR Issues
Alternatives considered
Tried to get the refresh to actually work for my use case but gave up since even fixing the linked issue with "withSchema" option didn't solve everything. Don't have the time currently to get into this code base well enough to dig deeper into that and I believe this change is a reasonable thing to have and it solves the issue we are seeing.