useDynamicUpdate & Snapshots

Hi there,

another day, another problem :)

I recently switched to using dynamic updates. I encountered a problem that the snapshots are not updated after saving the model.

So this code would cause problems:

            $exec->setIsRunning(1);

$exec->save();

            //Do some stuff

            $exec->setLastExecution($timestamp);
            $exec->setIsRunning(0);
            $exec->save();

Obviously setIsRunning(1) will work. But since update/save is not updating the snapshot and setting isRunning to 0 and lastExecution after some stuff is done will result in Phalcon only updating the timestamp. Outputting the snapshotData after the first save also shows that it differs from the actual model data.

So I solved this situation by updating the snapshotData by myself

protected function afterUpdate()

{ // We need to update the snapshot so that change -> save -> change -> save on a model instance would work $this->setSnapshotData($this->toArray()); }

protected function afterInsert()
{
    // We need to update the snapshot so that change -> save -> change -> save on a model instance would work
    $this->setSnapshotData($this->toArray());
}

But there has to be a better solution. Why does the framework not do this kind of things by itself ?

Greetings

Create issue on github with script to reprodeuce, it looks like a bug.