danielmewes / php-rql

A PHP client driver for the RethinkDB query language (ReQL).
http://php-rql.dnsalias.net/
339 stars 60 forks source link

orderBy does not support indexes #51

Closed danielmewes closed 10 years ago

danielmewes commented 10 years ago

The API documentation suggests that it does (http://php-rql.dnsalias.net/api/#ph:transformations-order_by), but it actually does not use indexes.

danielmewes commented 10 years ago

Apart from OrderBy itself, we must also update Asc and Desc.

wojons commented 10 years ago

@danielmewes can we get this fixed ran into this one right now thankfully @neumino was able to help me find this issue after we both tried a few things :)

danielmewes commented 10 years ago

A fix has been released in version 1.11.2 (this is the only change in that version).

It turned out that Asc and Desc don't have to be changed, because indexes cannot be used with those.

To use an index with name 'ind' in an orderBy: r\table('test')->orderBy(array('index' => 'ind'))

To combine an index with a secondary ordering criteria: r\table('test')->orderBy(array('index' => 'ind', 'other_field'))

danielmewes commented 10 years ago

Hmm, it seems that Asc and Desc can actually be combined with indexes. Re-opening.

danielmewes commented 10 years ago

Oh it actually already works: r\table('test')->orderBy(array('index' => r\desc('ind')))