Commit 5a96217d authored by beberlei's avatar beberlei

[2.0] DDC-328 - Query and Result Cache Keys now depend on the hydrationMode also

parent 8b2ca0d4
......@@ -548,7 +548,8 @@ abstract class AbstractQuery
} else {
$sql = $this->getSql();
ksort($this->_hints);
return md5(implode(";", (array)$sql) . var_export($params, true) . var_export($this->_hints, true));
return md5(implode(";", (array)$sql) . var_export($params, true) .
var_export($this->_hints, true)."&hydrationMode=".$this->_hydrationMode);
}
}
......
......@@ -448,7 +448,8 @@ final class Query extends AbstractQuery
return md5(
$this->getDql() . var_export($this->_hints, true) .
'firstResult='.$this->_firstResult.'&maxResult='.$this->_maxResults.'DOCTRINE_QUERY_CACHE_SALT'
'&firstResult=' . $this->_firstResult . '&maxResult=' . $this->_maxResults .
'&hydrationMode='.$this->_hydrationMode.'DOCTRINE_QUERY_CACHE_SALT'
);
}
}
\ No newline at end of file
......@@ -67,6 +67,19 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals($cacheCount + 1, count($cache->getIds()));
}
/**
* @param <type> $query
* @depends testQueryCache_DependsOnHints
*/
public function testQueryCache_DependsOnHydrationMode($query)
{
$cache = $query->getQueryCacheDriver();
$cacheCount = count($cache->getIds());
$query->getArrayResult();
$this->assertEquals($cacheCount + 1, count($cache->getIds()));
}
public function testQueryCache_NoHitSaveParserResult()
{
$this->_em->getConfiguration()->setQueryCacheImpl(null);
......
......@@ -131,4 +131,19 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals($cacheCount + 1, count($cache->getIds()));
}
/**
* @param <type> $query
* @depends testNativeQueryResultCaching
*/
public function testResultCacheDependsOnHydrationMode($query)
{
$cache = $query->getResultCacheDriver();
$cacheCount = count($cache->getIds());
$this->assertNotEquals(\Doctrine\ORM\Query::HYDRATE_ARRAY, $query->getHydrationMode());
$query->getArrayResult();
$this->assertEquals($cacheCount + 1, count($cache->getIds()));
}
}
\ No newline at end of file
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