fauna/cassandra — Issue #127: get_range with :start_key not working as expected
Author: Simbul
Created: 2011-11-08 18:16:34+00:00
State: open

I just stumbled into a weird get_range behaviour. Suppose we have a call such as:

cassandra.get_range(:CF, :start_key => "somekey", :key_count => 1)

What i would expect to get as a result is a structure with a single row with key "somekey" (regardless of the partitioner used).
Assuming that is the desired behaviour for `get_range`, something needs a fix, as you can see by running the following test (just drop it in test/cassandra_test.rb):

def test_get_one_key_with_start
hash = {"name" => "value"}
@twitter.insert(:Statuses, "a-key", hash)
@twitter.insert(:Statuses, "b-key", hash)
@twitter.insert(:Statuses, "c-key", hash)

results = @twitter.get_range(:Statuses, :start_key => "b-key", :key_count => 1)
assert_equal ["b-key"], results.keys
end

The test will return a failure with message:
<["b-key"]> expected but was
<["a-key"]>.

From a quick peek inside `cassandra.rb`, looks like the :start_key option is somehow discarded on line [758](https://github.com/fauna/cassandra/blob/98a6c6b74ccd02af6d2e8cecd8d22ef08fa92cf9/lib/cassandra/cassandra.rb#L758).