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.

Model snapshot seems to not work properly


im doing update setting exactly the same values to the model, yet Phalcon ORM showing me that some fields has changed. I've already found way around comparing new values before setting with entity/model values, and do setting only if they really change, but still... this is a bug...

Below is listing: first you have final values for setting, then snapshot data (before setting) and finally list of changed fields.

New values and snapshot data is exactly the same.

The problem is with: primary key (id), one of foreign keys (payer_country_id), and boolean fields. PostgreSQL database. There is other foreign key: ship_country_id, but there is no problem, maybe because it is NULL / empty.

setting id to [2]
setting creation_time to [2018-05-03 15:49:39.64878+02]
setting is_company to [0]
setting payer_name to [kolorofon 2]
setting payer_country_id to [116]
setting payer_address to [abc 12]
setting payer_city to [bb]
setting payer_zip_code to [43300]
setting payer_nip to []
setting email to [[email protected]]
setting telephone to []
setting login_pass to [$2y$10$U6lBCSh8MDjLCejYdVMcc.P9PM.Hwq/NKarweKpUmWegz15RGM0pq]
setting ship_name to []
setting ship_country_id to []
setting ship_address to []
setting ship_city to []
setting ship_zip_code to []
setting admin_notes to []
setting remind_pass_time to []
setting subscribe_newsletter to [1]
setting active to [1]
setting facebook_id to []
setting force_pass_change to [0]


    [id] => 2
    [creation_time] => 2018-05-03 15:49:39.64878+02
    [is_company] => 
    [payer_name] => kolorofon 2
    [payer_country_id] => 116
    [payer_address] => abc 12
    [payer_city] => bb
    [payer_zip_code] => 43300
    [payer_nip] => 
    [email] => [email protected]
    [telephone] => 
    [login_pass] => $2y$10$U6lBCSh8MDjLCejYdVMcc.P9PM.Hwq/NKarweKpUmWegz15RGM0pq
    [ship_name] => 
    [ship_country_id] => 
    [ship_address] => 
    [ship_city] => 
    [ship_zip_code] => 
    [admin_notes] => 
    [remind_pass_time] => 
    [subscribe_newsletter] => 1
    [active] => 1
    [facebook_id] => 
    [force_pass_change] => 

    [0] => id
    [1] => is_company
    [2] => payer_country_id
    [3] => subscribe_newsletter
    [4] => active
    [5] => force_pass_change

When I'll find time i'll try to report issue, and fix it by pulling request, but it will be not soon and im not fluent with Zphir / Github so maybe someone can do it faster and better,


Looks like your INTs are the one being triggered.. are you passing a "string" of "1" ?

Yes casting values to appropriate data types like boolean or integer before settings them to the Model has improved results.

But still there is some strange behaviors for some of the string columns when value of the field is pure number. Thats why on update I prefer to check if value changed compared to snapshot data using == operator before setting it, to be sure that changed fields detection is working properly.