cassandra-cql 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,9 +50,9 @@ module CassandraCQL
50
50
  end
51
51
 
52
52
  def column_values
53
- @row.columns.map { |column|
54
- @value_cache[column.name]
55
- }
53
+ column_names.map do |name|
54
+ @value_cache[name]
55
+ end
56
56
  end
57
57
 
58
58
  def columns
@@ -68,4 +68,4 @@ module CassandraCQL
68
68
  Hash[([column_names, column_values]).transpose]
69
69
  end
70
70
  end
71
- end
71
+ end
@@ -15,5 +15,5 @@ limitations under the License.
15
15
  =end
16
16
 
17
17
  module CassandraCQL
18
- VERSION = "1.1.2"
18
+ VERSION = "1.1.3"
19
19
  end
data/spec/row_spec.rb CHANGED
@@ -3,47 +3,74 @@ include CassandraCQL
3
3
 
4
4
 
5
5
  describe "basic methods" do
6
- before(:each) do
7
- @connection = setup_cassandra_connection
8
- if @connection.schema.column_family_names.include?('basic_methods')
9
- @connection.execute("DROP COLUMNFAMILY basic_methods")
10
- end
11
- @connection.execute("CREATE COLUMNFAMILY basic_methods (id varchar PRIMARY KEY, created_at uuid, default_column varchar, name varchar, serial int)")
6
+ context 'with basic column family' do
7
+ before(:each) do
8
+ @connection = setup_cassandra_connection
9
+ if @connection.schema.column_family_names.include?('basic_methods')
10
+ @connection.execute("DROP COLUMNFAMILY basic_methods")
11
+ end
12
+ @connection.execute("CREATE COLUMNFAMILY basic_methods (id varchar PRIMARY KEY, created_at uuid, default_column varchar, name varchar, serial int)")
12
13
 
13
- @connection.execute("INSERT INTO basic_methods (id, created_at, name, serial, default_column) VALUES (?, ?, ?, ?, ?)", 'test', Time.new, 'name', 12345, 'snork')
14
- @row = @connection.execute("SELECT * FROM basic_methods WHERE id=?", "test").fetch
15
- end
14
+ @connection.execute("INSERT INTO basic_methods (id, created_at, name, serial, default_column) VALUES (?, ?, ?, ?, ?)", 'test', Time.new, 'name', 12345, 'snork')
15
+ @row = @connection.execute("SELECT * FROM basic_methods WHERE id=?", "test").fetch
16
+ end
16
17
 
17
- context "column_names" do
18
- it "should return a list of column names" do
19
- @row.column_names.sort.should eq(["created_at", "default_column", "id", "name", "serial"].sort)
18
+ context "column_names" do
19
+ it "should return a list of column names" do
20
+ @row.column_names.sort.should eq(["created_at", "default_column", "id", "name", "serial"].sort)
21
+ end
20
22
  end
21
- end
22
23
 
23
- context "column_values" do
24
- it "should return a list of column values as Ruby objects" do
25
- @row.column_values.should be_kind_of(Array)
26
- @row.column_values.size.should eq(@row.column_names.size)
24
+ context "column_values" do
25
+ it "should return a list of column values as Ruby objects" do
26
+ @row.column_values.should be_kind_of(Array)
27
+ @row.column_values.size.should eq(@row.column_names.size)
28
+ end
29
+ end
30
+
31
+ context "columns" do
32
+ it "should equal the number of columns" do
33
+ @row.column_names.size.should eq(@row.column_values.size)
34
+ @row.columns.should eq(@row.column_names.size)
35
+ end
27
36
  end
28
- end
29
37
 
30
- context "columns" do
31
- it "should equal the number of columns" do
32
- @row.column_names.size.should eq(@row.column_values.size)
33
- @row.columns.should eq(@row.column_names.size)
38
+ context "checking casting" do
39
+ it "should return column_values for to_a" do
40
+ @row.to_a.should eq(@row.column_values)
41
+ end
42
+
43
+ it "should return a hash for to_hash" do
44
+ h = @row.to_hash
45
+ h.should be_kind_of(Hash)
46
+ h.keys.sort.should eq(@row.column_names.sort)
47
+ end
34
48
  end
35
49
  end
36
-
37
- context "checking casting" do
38
- it "should return column_values for to_a" do
39
- @row.to_a.should eq(@row.column_values)
50
+
51
+ context 'with a column family with int comparators' do
52
+ before(:each) do
53
+ @connection = setup_cassandra_connection
54
+ if @connection.schema.column_family_names.include?('int_comparator')
55
+ @connection.execute("DROP COLUMNFAMILY int_comparator")
56
+ end
57
+ @connection.execute("CREATE COLUMNFAMILY int_comparator (key text PRIMARY KEY) WITH comparator=int AND default_validation=text")
58
+
59
+ @connection.execute("INSERT INTO int_comparator (key, 1, 2) VALUES (?, ?, ?)", 'test', 'value1', 'value2')
60
+ @row = @connection.execute("SELECT * FROM int_comparator WHERE key=?", "test").fetch
61
+ end
62
+
63
+ context "column_names" do
64
+ it "should return a list of column names" do
65
+ @row.column_names.should =~ ['KEY', 1, 2]
66
+ end
40
67
  end
41
68
 
42
- it "should return a hash for to_hash" do
43
- h = @row.to_hash
44
- h.should be_kind_of(Hash)
45
- h.keys.sort.should eq(@row.column_names.sort)
69
+ context "column_values" do
70
+ it "should return a list of column values as Ruby objects" do
71
+ @row.column_values.should be_kind_of(Array)
72
+ @row.column_values.should =~ ['test', 'value1', 'value2']
73
+ end
46
74
  end
47
75
  end
48
-
49
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandra-cql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -211,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
211
  version: '0'
212
212
  segments:
213
213
  - 0
214
- hash: -3942152054633015494
214
+ hash: -2241138987958010983
215
215
  required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  none: false
217
217
  requirements: