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

synchronize clears all changes information, is there a way to sync data from the database but preserve previous_changes? #738

Open
nerdrew opened this issue Jul 6, 2021 · 1 comment

Comments

@nerdrew
Copy link

nerdrew commented Jul 6, 2021

Title says it all. I'd like to be able to synchronize data from the database (created_at, updated_at, autoinc id, etc), but still have previous_changes be correct. I'm trying to run before_* and after_* hooks, but my after hooks rely often check previous_changes to check if they should run.

Current behavior:

MyModel.import(new_records, synchronize: [new_records])
new_records[0].previous_changes #=> {}

(My) Expected behavior:

MyModel.import(new_records, synchronize: [new_records])
new_records[0].previous_changes #=> { id: [nil, 1], created_at: [nil, Time.now], updated_at: [nil, Time.now] }
@jkowens
Copy link
Collaborator

jkowens commented Jul 17, 2021

I do not believe so. Can you synchronize first then make changes to your model data?

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