Skip to content

Commit

Permalink
Don't emit errors when clauses are undefined.
Browse files Browse the repository at this point in the history
Refs #10734
  • Loading branch information
markstory committed Jun 7, 2017
1 parent 7b2ea59 commit 8782ba1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Database/Query.php
Expand Up @@ -1698,7 +1698,7 @@ public function getIterator()
*/
public function clause($name)
{
return $this->_parts[$name];
return isset($this->_parts[$name]) ? $this->_parts[$name] : null;
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/TestCase/Database/QueryTest.php
Expand Up @@ -4329,6 +4329,18 @@ public function testSelectWithObjFetchType()
$this->assertEquals($obj, $rows[0]);
}

/**
* Test that reading an undefined clause does not emit an error.
*
* @return void
*/
public function testClauseUndefined()
{
$query = new Query($this->connection);
$this->assertEmpty($query->clause('where'));
$this->assertNull($query->clause('nope'));
}

/**
* Assertion for comparing a table's contents with what is in it.
*
Expand Down

0 comments on commit 8782ba1

Please sign in to comment.