Skip to content

Commit

Permalink
fix: pass the column number 0 to the statement
Browse files Browse the repository at this point in the history
  • Loading branch information
tflori committed Jun 13, 2021
1 parent e4c1da6 commit 245bd09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/QueryBuilder/ExecutesQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public function setFetchMode($mode, $classNameObject = null, array $constructorA
return $this;
}

$statement->setFetchMode(...array_filter([$mode, $classNameObject, $constructorArgs]));
$statement->setFetchMode(...array_filter([$mode, $classNameObject, $constructorArgs], function ($p) {
return $p !== null;
}));
return $this;
}

Expand Down
15 changes: 15 additions & 0 deletions tests/QueryBuilder/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,19 @@ public function doesNotPassNull()

$query->setFetchMode(\PDO::FETCH_ASSOC, null);
}

/** @test */
public function passesColumnNumber0()
{
if (!extension_loaded('pdo_sqlite')) {
$this->markTestSkipped('pdo_sqlite extension required for this test');
}

$em = new EntityManager([
EntityManager::OPT_CONNECTION => new DbConfig('sqlite', '/tmp/test.sqlite')
]);
$query = $em->query('sqlite_master');

$query->setFetchMode(\PDO::FETCH_COLUMN, 0);
}
}

0 comments on commit 245bd09

Please sign in to comment.