Skip to content

Database refetch failed; row with signature 'xxx' does not exist! #187

@podolinek

Description

@podolinek
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions