Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Using array key to query fails #4

speedmax opened this Issue · 2 comments

2 participants


I have used previous version of couch_potato before its major rewrite, separating database operations do help ease on testing, but finger kinda hurts compare to the older version, i guess its a matter of judging how much automagic u need Vs. performance,

One of the thing that last major version works is using array as a key.. so you can do operations like following and it builds the map function as well as conversion of date range object into key.

Person.all(:key => [, 10.days.ago ..]) 

It kinda stopped working, i start poke around specs (custom_view_spec) and added following, It failes along with couple other specs start to blow up..

describe "with array as key" do
  it "should create a map function with the composite key" do
    CouchPotato::View::ViewQuery.should_receive(:new).with(anything, anything, anything, string_matching(/emit\(\[doc\['time'\], doc\['state'\]\]/), anything).and_return(stub('view query').as_null_object)
    CouchPotato.database.view Build.key_array_timeline

    CouchPotato.database.save_document => 'success', :time =>
    CouchPotato.database.save_document => 'success', :time =>

    result = CouchPotato.database.view(Build.timeline(:key => (, :descending => true))
    result.length.should > 0

The syntax of using range object as :key appears on the readme file, and test coverage of both array key and range object key are no where to be found

Can you update the current status on this one please ?

Great work by the way


for ranges please use the startkey and endkey parameters. if this is still in the readme then the readme is wrong and has to be updated. can you provide a test case for the array problem?

@langalex langalex closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.