- bug report? yes
- feature request? no
- version: 2.4.4.
Description
Hello guys, we found bug in method related() with combination with count(). If I need uncached column on cached result, nette database not recognize different in query for caching related(), if you call count() before foreach loop.. Without call count() it looks ok.
It creates InvalidStateException "Database refetch failed; row with signature '3' does not exist!"
In the shortest piece of code for explaining...
class HomepagePresenter extends BasePresenter {
/** @var @persistent */
public $test;
/** @var DocumentModel @inject */
public $document;
public function renderDefault() {
$source = $this->document->findAll()->where('document.name IS NOT NULL');
if ($this->test === true) {
$source->where(':document_item.is_visible', 1);
}
foreach ($source as $row) {
$items = $row->related('document_item');
if ($items->count()) {//if this is commented, everything is ok
foreach ($items as $item) {
if ($this->test === true) {
$item['is_visible'];
}
}
}
}
}
public function handleChangeState() {
$this->test = true;
}
}
In added sandbox with base logic you can try this. How to install and how to reproduce error in readme.md.
Description
Hello guys, we found bug in method
related()with combination withcount(). If I need uncached column on cached result, nette database not recognize different in query for cachingrelated(), if you callcount()before foreach loop.. Without callcount()it looks ok.It creates InvalidStateException "Database refetch failed; row with signature '3' does not exist!"
In the shortest piece of code for explaining...
In added sandbox with base logic you can try this. How to install and how to reproduce error in readme.md.