Permalink
Browse files

read from composite index

  • Loading branch information...
igrigorik committed Jan 14, 2011
1 parent 4c7d328 commit f6cb08fdef3b97811c3432cb8c9ef3607b77eed4
Showing with 20 additions and 2 deletions.
  1. +1 −1 Gemfile.lock
  2. +1 −1 lib/em-handlersocket/client.rb
  3. +18 −0 spec/client_spec.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- em-handlersocket (0.0.1)
+ em-handlersocket (0.1.0)
eventmachine
GEM
@@ -47,7 +47,7 @@ def open_index(opts)
end
def query(*queries)
- execute(queries.map{|q| [q[:id], q[:op], 1, q[:key], q[:limit], q[:offset]].compact })
+ execute(queries.map{|q| [q[:id], q[:op], q[:key].size, q[:key], q[:limit], q[:offset]].compact })
end
def execute(cmd, &blk)
View
@@ -101,4 +101,22 @@
}
end
+ it "should execute a query against a composite index" do
+ EM.run {
+ c = EM::HandlerSocket.new
+ idx = {:id => 0, :db => 'widgets', :table => 'user', :index_name => 'id_created', :columns => 'user_name'}
+
+ d = c.open_index(idx)
+ d.callback do |s|
+
+ d = c.query(:id => 0, :op => '>=', :key => ['2', '2010-01-03'])
+ d.errback { fail }
+ d.callback do |data|
+ data.should == ['Bob']
+ EM.stop
+ end
+ end
+ }
+ end
+
end

0 comments on commit f6cb08f

Please sign in to comment.