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
When passing null in the find method of the Model it returns non null value. Default vaue of $id should not be null or if it is null it should not query the database and return null
/**
* Fetches the row of database from $this->table with a primary key
* matching $id.
*
* @param mixed|array|null $id One primary key or an array of primary keys
*
* @return array|object|null The resulting row of data, or null.
*/
public function find($id = null)
{
$builder = $this->builder();
CodeIgniter 4 version
v4.0.0-rc.2.1
Affected module(s)
SYSTEMPATH/Model.php at line 354
Expected behavior, and steps to reproduce if appropriate
Should return null when $id is null
Context
OS: Ubuntu 16
Web server Apache/2.4.18
PHP version 7.3.9-1+ubuntu16.04.1+deb.sury.org+1
The text was updated successfully, but these errors were encountered:
jim-parry
changed the title
Model()->find(null) should return null value
Bug: Model()->find(null) should return null value
Oct 19, 2019
jim-parry
added
the
bug
Verified issues on the current code behavior or pull requests that will fix them
label
Oct 19, 2019
In this case this is the desired behavior since this method can also be used as part of chaining together commands that could include where's, etc. In that case, it could actually return results.
There was a big long discussion about this and other methods a year or so back and it was done this way for consistency with other core methods.
Describe the bug
When passing null in the find method of the Model it returns non null value. Default vaue of $id should not be null or if it is null it should not query the database and return null
CodeIgniter 4 version
v4.0.0-rc.2.1
Affected module(s)
SYSTEMPATH/Model.php at line 354
Expected behavior, and steps to reproduce if appropriate
Should return null when $id is null
Context
The text was updated successfully, but these errors were encountered: