elastic-search icon indicating copy to clipboard operation
elastic-search copied to clipboard

Update query options failed after executing query

Open andrii-pukhalevych opened this issue 3 years ago • 1 comments

Bug: calling select(), where() etc on \Cake\ElasticSearch\Query does not have any effect after executing all because in \Cake\Datasource\QueryTrait::all() its set to return previous results if available:

if ($this->_results !== null) {
    return $this->_results;
}

But \Cake\ElasticSearch\Query methods to change query options does not reset previous results like its done in \Cake\ORM\Query by calling _dirty().

Code example:

$Query = $this->loadModel('Articles', 'Elastic')->find()->select(['id2']);

$Query->where(['id2'=>'0a3f509f']);
var_dump($Query->all()->toArray());

$Query->where(['id2'=>'0a3f50b2'], [], true);
var_dump($Query->all()->toArray());

Last call still returns record 0a3f509f but have to return 0a3f50b2 instead.

andrii-pukhalevych avatar Oct 01 '21 15:10 andrii-pukhalevych

Looks like we're missing behavior like Database\Query::_dirty() provides ORM queries.

markstory avatar Oct 03 '21 02:10 markstory

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Dec 22 '22 00:12 github-actions[bot]

"closed this as completed" - its not completed

andrii-pukhalevych avatar Jan 07 '23 14:01 andrii-pukhalevych