Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Using array key to query fails #4

Closed
speedmax opened this Issue · 2 comments

2 participants

@speedmax

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 => [project.id, 10.days.ago .. 0.day.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 Build.new(:state => 'success', :time => Time.now-1000)
    CouchPotato.database.save_document Build.new(:state => 'success', :time => Time.now)

    result = CouchPotato.database.view(Build.timeline(:key => (Time.now-100000)..(Time.now), :descending => true))
    result.length.should > 0
  end
end
@speedmax

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

@langalex
Owner

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.