You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug Model::insert() throws exception when empty table is passed as parameter. It does not throw one when "empty object" is passed as parameter. For example, if I create a new Entity object and pass it as parameter, it won't throw exception while there is still no data to insert.
CodeIgniter 4 version
4.03
Affected module(s)
Codeigniter\Model
Expected behavior, and steps to reproduce if appropriate
Right after object is turned into array and before validation, that array should be rechecked for being empty or whole emptiness checking should be moved to that point in code.
@ -674,11 +674,6 @@ class Model
$this->tempData = [];
}
- if (empty($data))- {- throw DataException::forEmptyDataset('insert');- }
// If $data is using a custom class with public or protected
// properties representing the table elements, we need to grab
// them as an array.
@ -695,6 +690,11 @@ class Model
$data = (array) $data;
}
+ if (empty($data))+ {+ throw DataException::forEmptyDataset('insert');+ }
// Validate data before saving.
if ($this->skipValidation === false)
{
Context
OS: Windows 10
Web server: Apache 2.4.41
PHP version: 7.3.12
The text was updated successfully, but these errors were encountered:
SoulReaver
added
the
bug
Verified issues on the current code behavior or pull requests that will fix them
label
May 15, 2020
When fixing this, evaluate moving the data simplification outside of update and insert to
reduce duplicates
allow outside use (maybe in a override)
in my case overriding the save method to add a beforeSave event (with the data like beforeUpdate) leads me to copy 32 lines instead of calling something like dryEntityData($data)).
Describe the bug
Model::insert()
throws exception when empty table is passed as parameter. It does not throw one when "empty object" is passed as parameter. For example, if I create a newEntity
object and pass it as parameter, it won't throw exception while there is still no data to insert.CodeIgniter 4 version
4.03
Affected module(s)
Codeigniter\Model
Expected behavior, and steps to reproduce if appropriate
Right after object is turned into array and before validation, that array should be rechecked for being empty or whole emptiness checking should be moved to that point in code.
Context
The text was updated successfully, but these errors were encountered: