Skip to content

Bug: Builder (with field bool) #4761

Description

@dgavrilenko

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix themdatabaseIssues or pull requests that affect the database layer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions