Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Bug regarding getChangedFields and hasChanged

when you use snapshots there is a bug with null fields. It says fields doesn't changed when value is changed from null to 0. Values are compared with == not with ===. tested on 2.1 and 3.0.3 on both versions it says field doen't changed



839
Accepted
answer
edited Feb '17

On line 3904 of https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/model.zep#L3904

if value != snapshot[name] {

it should be something like:

if value !== snapshot[name] {

or even it should be checked if its changed fromm null or from '' to 0 and return true and return false when from 0 to '0'

Fixed in the 3.1.x branch. Thank you.