Unverified Commit e738a715 authored by Sergei Morozov's avatar Sergei Morozov

Merge branch 'bpo/2.9/#3686' into 2.9

parents 66f28111 08dca0d3
......@@ -166,7 +166,15 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$this->data = $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
$data = $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
if ($fetchMode === FetchMode::COLUMN) {
foreach ($data as $key => $value) {
$data[$key] = [$value];
}
}
$this->data = $data;
$this->emptied = true;
return $this->data;
......
......@@ -176,6 +176,22 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertCount(1, $layerCache->fetch('testcachekey'));
}
public function testFetchAllColumn() : void
{
$query = $this->connection->getDatabasePlatform()
->getDummySelectSQL('1');
$qcp = new QueryCacheProfile(0, 0, new ArrayCache());
$stmt = $this->connection->executeCacheQuery($query, [], [], $qcp);
$stmt->fetchAll(FetchMode::COLUMN);
$stmt->closeCursor();
$stmt = $this->connection->executeCacheQuery($query, [], [], $qcp);
self::assertEquals([1], $stmt->fetchAll(FetchMode::COLUMN));
}
public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchMode)
{
$stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment