-
Notifications
You must be signed in to change notification settings - Fork 2k
Bug: Builder (with field bool) #4761
Copy link
Copy link
Closed
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix themdatabaseIssues or pull requests that affect the database layerIssues or pull requests that affect the database layer
Description
Activity
Metadata
Metadata
Assignees
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix themdatabaseIssues or pull requests that affect the database layerIssues or pull requests that affect the database layer
Critical.
Env:
new core '4.1.2'
old core '4.0.4'
db PostgreSql.
os: ubuntu 18.
php 7.4
Hello, bug in Builder:
new core:
id exist in the database
$model = new Model();
$model->save((['id' => 1, 'field_bool' => false]); (works with true)
will give an error. (ErrorException)
old core:
$builder->set($data, '', null);
new core:
// Must use the set() method to ensure to set the correct escape flag
(system/Model.php line 320)
foreach ($data as $key => $val)
{
$builder->set($key, $val, $escape[$key] ?? null);
}
because of the type. false is converted to empty
public function set($key, ?string $value = '', bool $escape = null)
and works for the old kernel, since the $key is an array
also the difference builder (maybe it's ok)
$model = new Model();
$entity = new Entity([
'id' => 1,
'text' => true/false, (bool in string field)
]);
update text - 1/0 (new core)
save text true/false (old core)