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

Dynamic updates / snapshot data work correctly only once #11424

Closed
ioncube opened this issue Feb 17, 2016 · 7 comments
Closed

Dynamic updates / snapshot data work correctly only once #11424

ioncube opened this issue Feb 17, 2016 · 7 comments

Comments

@ioncube
Copy link

ioncube commented Feb 17, 2016

See: https://forum.phalconphp.com/discussion/10477/snapshot-data-not-updated-following-save-update-bug-limitation-u

When making a save() or update() to a model with snapshots in place, any subsequent changes and save/update to the model instance also include fields changed in prior updates but that have not changed since. It appears that snapshot data is not updated with the values applied during a save/update operation. This is inefficient and problematic if a prior update is not idempotent, such as using now().

It should be possible to make repeated change/update operations on a model and each time have only the changed fields updated as that is the purpose of the feature.

@nirnanaaa
Copy link

anyone working on this? In our case it is really anoying to perform a new find every time you just want to update a previously saved model.

@Jurigag
Copy link
Contributor

Jurigag commented Dec 8, 2016

So pretty much - save(if succesfull) should just update snapshot if needed ?

@duesentrieb26
Copy link

duesentrieb26 commented Dec 8, 2016

        $model = new Address();
        $model->setCity('Munich');

        if (!$model->save()) {
            print_r($model->getMessages());
        }

        $model->setStreet('test');

        if (!$model->save()) {
            print_r($model->getMessages());
        }

=> The record doesn't have a valid data snapshot

@virgofx
Copy link
Contributor

virgofx commented Dec 9, 2016

@Jurigag Did your recent changes for the cache snapshot fix this? Or is it related? Maybe we can fix both for 3.0.3 real quick

@Jurigag
Copy link
Contributor

Jurigag commented Dec 9, 2016

No, it's not related really, it's diffrent issue. I think that save method in model after successfull save should just update snapshot to current one which is not doing now ?

@Jurigag
Copy link
Contributor

Jurigag commented Mar 3, 2017

I made PR with fix for this, let me know what you think.

@sergeyklay
Copy link
Contributor

Fixed in the 3.1.x branch.

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

5 participants