-
Notifications
You must be signed in to change notification settings - Fork 2k
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 them
Description
PHP Version
7.4
CodeIgniter4 Version
4.4.8
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
cli
Database
Postgres 16
What happened?
When you map primary key in entity it will 'break' isset() on the database name. This causes getIdValue() (Model.php line 542) to return null even when the id exists which causes the save() function to assume everything is insert.
Steps to Reproduce
Entity
class Test extends Entity
{
protected $datamap = [
'id' => 'id_test_something'
];
....
}
Model
class TestModel extends Model {
protected $primaryKey = 'id_test_something';
....
....
$this->save($someTestEntity);
}
Expected Output
save() should decide to update.
Anything else?
Changing Model.php line 542 to
if (is_object($row) && $row->{$this->primaryKey} !== null) {
works, but I didn't test it.
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 them