Describe the bug
It seems we have an extra field/property after the query. The Entity::$original contains a foreign key: post_id, user_id..
In Relation::filterResults()Relation::filterResult(), we delete it, but there is no synchronization, unset from $attributes only.
| $this->model |
| ->select( |
| sprintf( |
| '%s.*, %s.%s', |
| $this->model->getTable(), |
| $this->many->pivotTable, |
| $this->many->pivotForeignKey, |
| ), |
| ) |
To Reproduce
Output debug object:
protected attributes -> array (5) [ 'id' => string (1) "1" 'name' => string (18) "Baking for dummies" 'total_hours' => string (2) "30" 'created_at' => string (19) "2025-10-06 18:55:21" 'updated_at' => string (19) "2025-10-06 18:55:21" ] protected original -> array (6) [ 'id' => string (1) "1" 'name' => string (18) "Baking for dummies" 'total_hours' => string (2) "30" 'created_at' => string (19) "2025-10-06 18:55:21" 'updated_at' => string (19) "2025-10-06 18:55:21" 'student_id' => string (1) "1" // <<< ]
Expected behavior
Unnecessary properties are not needed.
Screenshots
No.
Environment (please complete the following information):
- PHP: PHP 8.4.13
- Version: dev-latest
- CodeIgniter: 4.6.3
Additional context
I tried to add synchronization to the right places, but it looks terrible. Maybe you know a better solution.
See also HasRelations::getDataForRelationByIds(), HasRelations::getDataForRelationById().
You can add array processing at the end of return $row->syncOriginal()
I think the object should be 100% synchronized after all the manipulations, because new values are being added.
Describe the bug
It seems we have an extra field/property after the query. The
Entity::$originalcontains a foreign key: post_id, user_id..In
Relation::filterResults()Relation::filterResult(), we delete it, but there is no synchronization, unset from$attributesonly.codeigniter-nested-model/src/Relation.php
Lines 164 to 172 in cf01743
To Reproduce
Output debug object:
Expected behavior
Unnecessary properties are not needed.
Screenshots
No.
Environment (please complete the following information):
Additional context
I tried to add synchronization to the right places, but it looks terrible. Maybe you know a better solution.
See also
HasRelations::getDataForRelationByIds(), HasRelations::getDataForRelationById().You can add array processing at the end of return
$row->syncOriginal()I think the object should be 100% synchronized after all the manipulations, because new values are being added.