Skip to content

Bug: Model()->find(null) should return null value #2350

Description

@SunilEver

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

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