Commit 10edf5c9 by Klimov Paul

`yii\sphinx\ActiveQuery` fixed to be resuable.

parent 981fbadd
......@@ -248,12 +248,14 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->setConnection($db);
$db = $this->getConnection();
$params = $this->params;
if ($this->sql === null) {
list ($this->sql, $params) = $db->getQueryBuilder()->build($this);
list ($sql, $params) = $db->getQueryBuilder()->build($this);
} else {
$sql = $this->sql;
$params = $this->params;
}
return $db->createCommand($this->sql, $params);
return $db->createCommand($sql, $params);
}
/**
......
......@@ -234,4 +234,14 @@ class ActiveRecordTest extends SphinxTestCase
$this->assertArrayHasKey('tokenized', $rows[0], 'No tokenized keyword!');
$this->assertArrayHasKey('normalized', $rows[0], 'No normalized keyword!');
}
/**
* @depends testFind
*/
public function testFindQueryReuse()
{
$result = ArticleIndex::find()->andWhere(['author_id' => 1]);
$this->assertTrue($result->one() instanceof ArticleIndex);
$this->assertTrue($result->one() instanceof ArticleIndex);
}
}
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