Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distinct on get_all()/between() #3346

Closed
nviennot opened this issue Nov 17, 2014 · 7 comments
Closed

distinct on get_all()/between() #3346

nviennot opened this issue Nov 17, 2014 · 7 comments
Assignees
Milestone

Comments

@nviennot
Copy link
Contributor

r.between(:index => :some_index).distinct does not work. RethinkDB complains that the id index and the some_index index are both being used. However, get_all() works fine. Example:

#!/usr/bin/env ruby
require 'rethinkdb'
include RethinkDB::Shortcuts

r.connect(:host => 'localhost', :port => 28015, :db => :test).repl
r.db_drop(:test).run rescue nil
r.db_create(:test).run
r.table_create(:table).run

r.table(:table).index_create(:field1).run

# returns 0
puts r.table(:table).get_all(1,3, :index => :field1).distinct.count.run

# raises Cannot use 2 indexes in the same operation. Trying to use field1 and id (RethinkDB::RqlRuntimeError)
puts r.table(:table).between(1,3, :index => :field1).distinct.count.run
@danielmewes danielmewes added this to the 1.15.x milestone Nov 17, 2014
@danielmewes
Copy link
Member

That seems to be a bug, sorry you ran into it.

Pinging @mlucy

@mlucy
Copy link
Member

mlucy commented Nov 17, 2014

This is indeed a bug. A fix is in CR 2321 by @danielmewes .

@nviennot
Copy link
Contributor Author

How do I retrieve the server version?
I need to know the server version so that I can apply a coerce_to('array') as a workaround on the buggy between() to allow distinct() to work.
Can we have something similar to http://redis.io/commands/info ? but maybe with some sort of fake table or something, whatever makes sense for you?

@danielmewes
Copy link
Member

You'll be able to get the server version from a "pseudo table" starting with RethinkDB 1.16 (it will be in r.db('rethinkdb').table('server_status')).
Right now it's not available through ReQL unfortunately.

As long as the between/get_all are run on a multi-index, always adding the coerce_to('array') is probably fine. distinct() is going to do the same thing internally anyway in those cases.

@mlucy
Copy link
Member

mlucy commented Nov 19, 2014

This is in next and v1.15.x. (@danielmewes, despite what I told you in person a second ago, the changes in next were almost exactly analagous to the changes in 1.15.x, it just didn't look like it at first because one of the types had changed so the merge conflict looked much messier than it actually was.)

@mlucy mlucy closed this as completed Nov 19, 2014
@danielmewes danielmewes mentioned this issue Dec 9, 2014
@AtnNn AtnNn modified the milestones: 1.15.3, 1.15.x Dec 16, 2014
@AtnNn
Copy link
Member

AtnNn commented Jan 9, 2015

@nviennot A fix has been released in RethinkDB 1.15.3

@nviennot
Copy link
Contributor Author

nviennot commented Jan 9, 2015

nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants