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.
- data/lib/cassandra-cql/row.rb +4 -4
- data/lib/cassandra-cql/version.rb +1 -1
- data/spec/row_spec.rb +58 -31
- metadata +2 -2
data/lib/cassandra-cql/row.rb
CHANGED
@@ -50,9 +50,9 @@ module CassandraCQL
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def column_values
|
53
|
-
|
54
|
-
@value_cache[
|
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
|
data/spec/row_spec.rb
CHANGED
@@ -3,47 +3,74 @@ include CassandraCQL
|
|
3
3
|
|
4
4
|
|
5
5
|
describe "basic methods" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@connection.
|
10
|
-
|
11
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
38
|
-
|
39
|
-
@
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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.
|
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: -
|
214
|
+
hash: -2241138987958010983
|
215
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
216
|
none: false
|
217
217
|
requirements:
|