From be583a7a228920f41e2b5c966a65965152f6fbe4 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 27 Nov 2013 23:26:10 +0100 Subject: [PATCH] fixed problem with sorting by id in elasticsearch issue #1317 --- extensions/elasticsearch/QueryBuilder.php | 2 +- tests/unit/extensions/elasticsearch/ActiveRecordTest.php | 2 +- tests/unit/framework/ar/ActiveRecordTestTrait.php | 10 ---------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/extensions/elasticsearch/QueryBuilder.php b/extensions/elasticsearch/QueryBuilder.php index 63cfe6e..5ed77e6 100644 --- a/extensions/elasticsearch/QueryBuilder.php +++ b/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/ diff --git a/tests/unit/extensions/elasticsearch/ActiveRecordTest.php b/tests/unit/extensions/elasticsearch/ActiveRecordTest.php index 72b5c5d..ccdc90f 100644 --- a/tests/unit/extensions/elasticsearch/ActiveRecordTest.php +++ b/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); diff --git a/tests/unit/framework/ar/ActiveRecordTestTrait.php b/tests/unit/framework/ar/ActiveRecordTestTrait.php index 9cd65b9..75e2120 100644 --- a/tests/unit/framework/ar/ActiveRecordTestTrait.php +++ b/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);