Skip to content

Commit

Permalink
Merge branch 'hotfix/ZF2-418' of git://github.com/postalservice14/zf2…
Browse files Browse the repository at this point in the history
… into postalservice14-hotfix/ZF2-418
  • Loading branch information
Ralph Schindler committed Aug 1, 2012
2 parents e058886 + 225aad1 commit 47ba77b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions library/Zend/Db/Sql/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public function set(array $values, $flag = self::VALUES_SET)
*/
public function where($predicate, $combination = Predicate\PredicateSet::OP_AND)
{
if (is_null($predicate)) {
throw new \Zend\Db\Sql\Exception\InvalidArgumentException('Predicate cannot be null');
}

if ($predicate instanceof Where) {
$this->where = $predicate;
} elseif ($predicate instanceof \Closure) {
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Db/TableGateway/AbstractTableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function update($set, $where = null)
$sql = $this->sql;
$update = $sql->update();
$update->set($set);
$update->where($where);
if (!is_null($where)) $update->where($where);
return $this->executeUpdate($update);
}

Expand Down
13 changes: 13 additions & 0 deletions tests/Zend/Db/TableGateway/AbstractTableGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ public function testUpdate()
$this->assertEquals(5, $affectedRows);
}

/**
* @covers Zend\Db\TableGateway\AbstractTableGateway::update
* @covers Zend\Db\TableGateway\AbstractTableGateway::updateWith
* @covers Zend\Db\TableGateway\AbstractTableGateway::executeUpdate
*/
public function testUpdateWithNoCriteria()
{
$mockUpdate = $this->mockSql->update();

$affectedRows = $this->table->update(array('foo' => 'bar'));
$this->assertEquals(5, $affectedRows);
}

/**
* @covers Zend\Db\TableGateway\AbstractTableGateway::delete
* @covers Zend\Db\TableGateway\AbstractTableGateway::deleteWith
Expand Down

0 comments on commit 47ba77b

Please sign in to comment.