Skip to content

Bug: CI4 set ID to NULL when I try insert a row #2557

Closed
@MashinaMashina

Description

@MashinaMashina

This code:

if (! empty($properties) && ! empty($primaryKey) && ! in_array($primaryKey, $properties))
{
	$properties[$primaryKey] = $data->{$primaryKey};
}

breaks all my app. When I try to insert a row, in example this row:
name: John
age: 21

CodeIgniter add field from primaryKey and fill value to NULL. And postgres got error because id can`t be null

Code for reproduction:

$user = new App\Entities\User;
$user->fill([
	'name' => 'John',
	'age'  => 21,
]);

$userModel->save($user);
// and we get error because primary key of userModel can`t be null

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 them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions