Skip to content

Commit

Permalink
fixing exists? when given only a key. fixes cassandra-rb#26.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhodges committed May 13, 2010
1 parent e9e8ed0 commit e3fefa3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/cassandra/cassandra.rb
Expand Up @@ -213,7 +213,11 @@ def multi_get(column_family, keys, *columns_and_options)
def exists?(column_family, key, *columns_and_options)
column_family, column, sub_column, options =
extract_and_validate_params(column_family, key, columns_and_options, READ_DEFAULTS)
_multiget(column_family, [key], column, sub_column, 1, nil, nil, nil, options[:consistency])[key]
if column
_multiget(column_family, [key], column, sub_column, 1, nil, nil, nil, options[:consistency])[key]
else
_multiget(column_family, [key], nil, nil, 1, '', '', false, options[:consistency])[key]
end
end

# Return a list of keys in the column_family you request. Requires the
Expand Down
5 changes: 5 additions & 0 deletions test/cassandra_test.rb
Expand Up @@ -94,6 +94,11 @@ def test_get_value
assert !@twitter.exists?(:Statuses, 'bogus', 'body')
end

def test_exists_with_only_key
@twitter.insert(:Statuses, key, {'body' => 'v'})
assert @twitter.exists?(:Statuses, key)
end

def test_get_super_key
columns = {'user_timelines' => {@uuids[4] => '4', @uuids[5] => '5'}}
@twitter.insert(:StatusRelationships, key, columns)
Expand Down

0 comments on commit e3fefa3

Please sign in to comment.