bupy7 / yii2-activerecord-history

This extension adds storage history of changes to the ActiveRecord model.
26 stars 17 forks source link

Handle yii\db\Expression #3

Closed Eseperio closed 6 years ago

Eseperio commented 6 years ago

Skip attributes behavior should be done before comparing values.

If you use an expression in other behaviors history will fail.

Explanation.

When a behavior uses a db expression to set the value, history behavior fails. That is because it expects that all values are comparable.

'timestamp' => [
                'class' => TimestampBehavior::className(),
                'value' => new \yii\db\Expression('NOW()'),
            ],
bupy7 commented 6 years ago

Hi! Yes, I agree with you. Could you please make a pull request?

Eseperio commented 6 years ago

Well, the title is wrong. My PR does not fix this problem, it ensures that skipped attributes are ignored before comparing value. I think it has no sense to register the history of a field that generates itself.

bupy7 commented 6 years ago

Fixed in v1.1.0