Browse Source

fixed problem with sorting by id in elasticsearch

issue #1317
tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
be583a7a22
  1. 2
      extensions/elasticsearch/QueryBuilder.php
  2. 2
      tests/unit/extensions/elasticsearch/ActiveRecordTest.php
  3. 10
      tests/unit/framework/ar/ActiveRecordTestTrait.php

2
extensions/elasticsearch/QueryBuilder.php

@ -116,7 +116,7 @@ class QueryBuilder extends \yii\base\Object
$column = $name;
}
if ($column == ActiveRecord::PRIMARY_KEY_NAME) {
$column = '_id';
$column = '_uid';
}
// allow elasticsearch extended syntax as described in http://www.elasticsearch.org/guide/reference/api/search/sort/

2
tests/unit/extensions/elasticsearch/ActiveRecordTest.php

@ -231,11 +231,11 @@ class ActiveRecordTest extends ElasticSearchTestCase
public function testFindEagerViaRelation()
{
// this test is currently failing randomly because of https://github.com/yiisoft/yii2/issues/1310
$orders = Order::find()->with('items')->orderBy('create_time')->all();
$this->assertEquals(3, count($orders));
$order = $orders[0];
$this->assertEquals(1, $order->id);
$this->assertTrue($order->isRelationPopulated('items'));
$this->assertEquals(2, count($order->items));
$this->assertEquals(1, $order->items[0]->id);
$this->assertEquals(2, $order->items[1]->id);

10
tests/unit/framework/ar/ActiveRecordTestTrait.php

@ -295,11 +295,6 @@ trait ActiveRecordTestTrait
public function testFindLimit()
{
if (getenv('TRAVIS') == 'true' && $this instanceof \yiiunit\extensions\elasticsearch\ActiveRecordTest) {
// https://github.com/yiisoft/yii2/issues/1317
$this->markTestSkipped('This test is unreproduceable failing on travis-ci, locally it is passing.');
}
/** @var TestCase|ActiveRecordTestTrait $this */
// all()
$customers = $this->callCustomerFind()->all();
@ -420,11 +415,6 @@ trait ActiveRecordTestTrait
public function testFindLazyVia()
{
if (getenv('TRAVIS') == 'true' && $this instanceof \yiiunit\extensions\elasticsearch\ActiveRecordTest) {
// https://github.com/yiisoft/yii2/issues/1317
$this->markTestSkipped('This test is unreproduceable failing on travis-ci, locally it is passing.');
}
/** @var TestCase|ActiveRecordTestTrait $this */
/** @var Order $order */
$order = $this->callOrderFind(1);

Loading…
Cancel
Save