Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Fixes #4926
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Feb 15, 2014
1 parent fdaa70a commit 4e6f7a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Db/Sql/Insert.php
Expand Up @@ -91,7 +91,7 @@ public function columns(array $columns)
*/
public function values(array $values, $flag = self::VALUES_SET)
{
if ($values == null) {
if (!is_array($values)) {

This comment has been minimized.

Copy link
@kkamkou

kkamkou Feb 16, 2014

Does this check/message make any sense here?

This comment has been minimized.

Copy link
@samsonasik

samsonasik Feb 16, 2014

Author Contributor

yes, so, we can do

$table->insert(array());

see issue #4926

This comment has been minimized.

Copy link
@kkamkou

kkamkou Feb 16, 2014

Problem was in typecasting and not in the validation. lines 94-96 are useless.

This comment has been minimized.

Copy link
@samsonasik

samsonasik Feb 16, 2014

Author Contributor

I think you better create PR if you have better suggestion, thanks.

throw new Exception\InvalidArgumentException('values() expects an array of values');
}

Expand Down
9 changes: 9 additions & 0 deletions tests/ZendTest/Db/Sql/InsertTest.php
Expand Up @@ -72,6 +72,15 @@ public function testValues()
$this->assertEquals(array('bax'), $this->readAttribute($this->insert, 'values'));
}

/**
* @covers Zend\Db\Sql\Insert::values
* @group ZF2-4926
*/
public function testEmptyArrayValues()
{
$this->insert->values(array());
$this->assertEquals(array(), $this->readAttribute($this->insert, 'columns'));
}

/**
* @covers Zend\Db\Sql\Insert::prepareStatement
Expand Down

0 comments on commit 4e6f7a5

Please sign in to comment.