cphalcon: [BUG]: Model - Update - Postgres Bool False/True Not Working Phalcon 4 [temp fix at the end]
When I try to save a boolean value on postgresql, it does not save;
$model->getMessages() "return field1,field2,field3… is required
Do not work If I use true/false
$find = Model::findFirst('id='.$id);
Return Bool fine The fields area NOT NULL DEFAULT true/false;
["enabled"]=> | bool(true)
| ["allowed"]=> | bool(true)
["restrict"]=>| bool(false)
Do not Work
Throw required field allowed and enabled
$find->label = 'Test';
$find->save();
Manually.
Do not Work If i want to change the value or auto update the column;
$find->enabled= false
$find->allowed= true.
$find->restrict = false
$find->save();
Work
$find->enabled= 0
$find->allowed= 1....
$find->restrict = 0
$find->save();
Work On Create
Return values empty on object after create. And i don’t need to set all fields values, does not set bool field as required
$find= new Model();
$find->enabled= false
$find->allowed= true.
$find ->save();
$find->assign(['test' => false])->update();
Works if I use 0/1
$find->assign(['test' => 0,])->update();
Config Phalcon 4.0.2 / PHP 7.4.1 / Postgresql 12.1/Nginx 1.16.1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (22 by maintainers)
Commits related to this issue
- Fix Boolean Type Remove is numeric for boolean type Related to this bug. https://github.com/phalcon/cphalcon/issues/14722 — committed to rzx10r/cphalcon by rzx10r 4 years ago
- Fix Boolean Type Remove is numeric for boolean type Related to this bug. https://github.com/phalcon/cphalcon/issues/14722 — committed to phalcon/cphalcon by rzx10r 4 years ago
Resolved in https://github.com/phalcon/cphalcon/pull/14781
Thank you again @tidytrax for the report, investigation and fix
The hydrate stuff is not for this issue.
I tried this on Postgres 12 but unable to reproduce this behaviour. Can you share your model?