Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Row column_[names,values] will only return columns. #5

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/cassandra-cql/row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ def [](obj)
end

def column_names
@names ||= @row.columns.map { |column| ColumnFamily.cast(column.name, @column_family.comparator_type) }
key_alias = @column_family.key_alias
@names ||= @row.columns.select {|column| column.name != key_alias}.map { |column| ColumnFamily.cast(column.name, @column_family.comparator_type) }
end

def column_values
@values ||= @row.columns.map { |column| ColumnFamily.cast(column.value, @column_family.columns[column.name]) }
key_alias = @column_family.key_alias
@values ||= @row.columns.select {|column| column.name != key_alias}.map { |column| ColumnFamily.cast(column.value, @column_family.columns[column.name]) }
end

def columns
@row.columns.size
end
Expand All @@ -38,4 +40,4 @@ def key
ColumnFamily.cast(@row.key, @column_family.key_validation_class)
end
end
end
end
4 changes: 2 additions & 2 deletions spec/row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

context "column_names" do
it "should return a list of column names" do
row.column_names.sort.should eq(["created_at", "default_column", "id", "name", "serial"].sort)
row.column_names.sort.should eq(["created_at", "default_column", "name", "serial"].sort)
end
end

Expand All @@ -41,7 +41,7 @@
end

it "should return a String for id" do
row['id'].should be_kind_of(String)
row.key.should be_kind_of(String)
end

it "should return a String for default_column" do
Expand Down