cequel 1.10.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +93 -65
- data/README.md +26 -5
- data/Vagrantfile +2 -2
- data/lib/cequel/errors.rb +2 -0
- data/lib/cequel/instrumentation.rb +5 -4
- data/lib/cequel/metal/batch.rb +21 -18
- data/lib/cequel/metal/data_set.rb +17 -28
- data/lib/cequel/metal/inserter.rb +3 -2
- data/lib/cequel/metal/keyspace.rb +56 -33
- data/lib/cequel/metal/request_logger.rb +22 -8
- data/lib/cequel/metal/row_specification.rb +9 -8
- data/lib/cequel/metal/statement.rb +23 -7
- data/lib/cequel/metal/updater.rb +12 -10
- data/lib/cequel/metal/writer.rb +5 -13
- data/lib/cequel/record/association_collection.rb +6 -33
- data/lib/cequel/record/collection.rb +2 -1
- data/lib/cequel/record/errors.rb +6 -0
- data/lib/cequel/record/persistence.rb +2 -2
- data/lib/cequel/record/record_set.rb +3 -4
- data/lib/cequel/record/validations.rb +5 -5
- data/lib/cequel/schema/table.rb +3 -5
- data/lib/cequel/schema/table_reader.rb +73 -111
- data/lib/cequel/schema/table_updater.rb +9 -15
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/metal/data_set_spec.rb +34 -46
- data/spec/examples/metal/keyspace_spec.rb +8 -6
- data/spec/examples/record/associations_spec.rb +8 -18
- data/spec/examples/record/persistence_spec.rb +6 -6
- data/spec/examples/record/record_set_spec.rb +39 -12
- data/spec/examples/record/timestamps_spec.rb +12 -5
- data/spec/examples/schema/keyspace_spec.rb +13 -37
- data/spec/examples/schema/table_reader_spec.rb +4 -1
- data/spec/examples/schema/table_updater_spec.rb +22 -7
- data/spec/examples/schema/table_writer_spec.rb +2 -3
- data/spec/examples/spec_helper.rb +1 -0
- data/spec/examples/spec_support/preparation_spec.rb +14 -7
- metadata +7 -8
@@ -28,10 +28,14 @@ describe Cequel::Record::Timestamps do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should update updated_at after record update but not created_at' do
|
31
|
-
|
31
|
+
before = now
|
32
|
+
sleep 1
|
33
|
+
after = Time.now
|
34
|
+
|
32
35
|
blog.name = 'name'
|
33
36
|
blog.save!
|
34
|
-
expect(blog.
|
37
|
+
expect(blog.created_at).to be_within(one_millisecond).of(before)
|
38
|
+
expect(blog.updated_at).to be_within(one_millisecond).of(after)
|
35
39
|
end
|
36
40
|
|
37
41
|
it 'should cast the timestamp in the same way that Cassandra records it' do
|
@@ -55,11 +59,14 @@ describe Cequel::Record::Timestamps do
|
|
55
59
|
end
|
56
60
|
|
57
61
|
it 'should update updated_at after record update but not created_at' do
|
58
|
-
|
62
|
+
before = now
|
63
|
+
sleep 1
|
64
|
+
after = Time.now
|
65
|
+
|
59
66
|
post.name = 'name'
|
60
67
|
post.save!
|
61
|
-
expect(post.created_at).to be_within(one_millisecond).of(
|
62
|
-
expect(post.updated_at).to be_within(one_millisecond).of(
|
68
|
+
expect(post.created_at).to be_within(one_millisecond).of(before)
|
69
|
+
expect(post.updated_at).to be_within(one_millisecond).of(after)
|
63
70
|
end
|
64
71
|
end
|
65
72
|
end
|
@@ -29,7 +29,7 @@ describe Cequel::Schema::Keyspace do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
let(:schema_config) do
|
32
|
-
connection.
|
32
|
+
connection.send(:cluster).tap{|x| x.refresh_schema}.keyspace(keyspace_name)
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'with default options' do
|
@@ -37,12 +37,8 @@ describe Cequel::Schema::Keyspace do
|
|
37
37
|
|
38
38
|
it 'uses default keyspace configuration' do
|
39
39
|
keyspace.create!
|
40
|
-
expect(schema_config).to eq
|
41
|
-
|
42
|
-
"durable_writes"=>true,
|
43
|
-
"strategy_class"=>"org.apache.cassandra.locator.SimpleStrategy",
|
44
|
-
"strategy_options"=>"{\"replication_factor\":\"1\"}"
|
45
|
-
})
|
40
|
+
expect(schema_config.name).to eq keyspace_name
|
41
|
+
expect(schema_config.durable_writes?).to eq true
|
46
42
|
end
|
47
43
|
end
|
48
44
|
|
@@ -51,12 +47,8 @@ describe Cequel::Schema::Keyspace do
|
|
51
47
|
|
52
48
|
it 'uses specified options' do
|
53
49
|
keyspace.create! replication: { class: "SimpleStrategy", replication_factor: 2 }
|
54
|
-
expect(schema_config).to eq
|
55
|
-
|
56
|
-
"durable_writes"=>true,
|
57
|
-
"strategy_class"=>"org.apache.cassandra.locator.SimpleStrategy",
|
58
|
-
"strategy_options"=>"{\"replication_factor\":\"2\"}"
|
59
|
-
})
|
50
|
+
expect(schema_config.name).to eq keyspace_name
|
51
|
+
expect(schema_config.durable_writes?).to eq true
|
60
52
|
end
|
61
53
|
end
|
62
54
|
|
@@ -65,12 +57,8 @@ describe Cequel::Schema::Keyspace do
|
|
65
57
|
|
66
58
|
it 'accepts class and replication_factor options' do
|
67
59
|
keyspace.create! class: "SimpleStrategy", replication_factor: 2
|
68
|
-
expect(schema_config).to eq
|
69
|
-
|
70
|
-
"durable_writes"=>true,
|
71
|
-
"strategy_class"=>"org.apache.cassandra.locator.SimpleStrategy",
|
72
|
-
"strategy_options"=>"{\"replication_factor\":\"2\"}"
|
73
|
-
})
|
60
|
+
expect(schema_config.name).to eq keyspace_name
|
61
|
+
expect(schema_config.durable_writes?).to eq true
|
74
62
|
end
|
75
63
|
|
76
64
|
it "raises an error if a class other than SimpleStrategy is given" do
|
@@ -87,12 +75,8 @@ describe Cequel::Schema::Keyspace do
|
|
87
75
|
|
88
76
|
it 'uses default keyspace configuration' do
|
89
77
|
keyspace.create!
|
90
|
-
expect(schema_config).to eq
|
91
|
-
|
92
|
-
"durable_writes"=>true,
|
93
|
-
"strategy_class"=>"org.apache.cassandra.locator.SimpleStrategy",
|
94
|
-
"strategy_options"=>"{\"replication_factor\":\"3\"}"
|
95
|
-
})
|
78
|
+
expect(schema_config.name).to eq keyspace_name
|
79
|
+
expect(schema_config.durable_writes?).to eq true
|
96
80
|
end
|
97
81
|
end
|
98
82
|
|
@@ -103,12 +87,8 @@ describe Cequel::Schema::Keyspace do
|
|
103
87
|
|
104
88
|
it 'uses default keyspace configuration' do
|
105
89
|
keyspace.create!
|
106
|
-
expect(schema_config).to eq
|
107
|
-
|
108
|
-
"durable_writes"=>true,
|
109
|
-
"strategy_class"=>"org.apache.cassandra.locator.NetworkTopologyStrategy",
|
110
|
-
"strategy_options"=>"{\"datacenter1\":\"3\",\"datacenter2\":\"2\"}"
|
111
|
-
})
|
90
|
+
expect(schema_config.name).to eq keyspace_name
|
91
|
+
expect(schema_config.durable_writes?).to eq true
|
112
92
|
end
|
113
93
|
end
|
114
94
|
|
@@ -119,12 +99,8 @@ describe Cequel::Schema::Keyspace do
|
|
119
99
|
|
120
100
|
it 'uses default keyspace configuration' do
|
121
101
|
keyspace.create!
|
122
|
-
expect(schema_config).to eq
|
123
|
-
|
124
|
-
"durable_writes"=>false,
|
125
|
-
"strategy_class"=>"org.apache.cassandra.locator.SimpleStrategy",
|
126
|
-
"strategy_options"=>"{\"replication_factor\":\"1\"}"
|
127
|
-
})
|
102
|
+
expect(schema_config.name).to eq keyspace_name
|
103
|
+
expect(schema_config.durable_writes?).to eq false
|
128
104
|
end
|
129
105
|
end
|
130
106
|
end # describe 'creating keyspace'
|
@@ -13,6 +13,7 @@ describe Cequel::Schema::TableReader do
|
|
13
13
|
describe 'reading simple key' do
|
14
14
|
before do
|
15
15
|
cequel.execute("CREATE TABLE #{table_name} (permalink text PRIMARY KEY)")
|
16
|
+
cequel.send(:cluster).refresh_schema
|
16
17
|
end
|
17
18
|
|
18
19
|
it 'should read name correctly' do
|
@@ -295,8 +296,10 @@ describe Cequel::Schema::TableReader do
|
|
295
296
|
end
|
296
297
|
|
297
298
|
it 'should read and simplify compression class' do
|
298
|
-
expect(table.property(:compression)[:sstable_compression]
|
299
|
+
expect(table.property(:compression)[:sstable_compression] ||
|
300
|
+
table.property(:compression)[:class]).
|
299
301
|
to eq('DeflateCompressor')
|
302
|
+
|
300
303
|
end
|
301
304
|
|
302
305
|
it 'should read integer properties from compression class' do
|
@@ -121,16 +121,31 @@ describe Cequel::Schema::TableUpdater do
|
|
121
121
|
end
|
122
122
|
|
123
123
|
describe '#drop_index' do
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
124
|
+
context 'index exists' do
|
125
|
+
before do
|
126
|
+
tab_name = table_name
|
127
|
+
cequel.schema.alter_table(table_name) do
|
128
|
+
create_index :title
|
129
|
+
drop_index :"#{tab_name}_title_idx"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'should drop the index' do
|
134
|
+
expect(table.data_column(:title)).not_to be_indexed
|
129
135
|
end
|
130
136
|
end
|
131
137
|
|
132
|
-
|
133
|
-
|
138
|
+
context 'index does not exist' do
|
139
|
+
before do
|
140
|
+
tab_name = table_name
|
141
|
+
cequel.schema.alter_table(table_name) do
|
142
|
+
drop_index :"#{tab_name}_title_idx"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should nop on non existent index' do
|
147
|
+
expect(table.data_column(:title)).not_to be_indexed
|
148
|
+
end
|
134
149
|
end
|
135
150
|
end
|
136
151
|
|
@@ -167,10 +167,9 @@ describe Cequel::Schema::TableWriter do
|
|
167
167
|
end
|
168
168
|
|
169
169
|
it 'should set map collection properties' do
|
170
|
-
expect(table.property(:compression)).to
|
171
|
-
:sstable_compression => 'DeflateCompressor',
|
170
|
+
expect(table.property(:compression)).to include(
|
172
171
|
:chunk_length_kb => 64
|
173
|
-
|
172
|
+
)
|
174
173
|
end
|
175
174
|
end
|
176
175
|
|
@@ -63,11 +63,12 @@ describe Cequel::SpecSupport::Preparation do
|
|
63
63
|
|
64
64
|
it "allows keyspace can be created" do
|
65
65
|
prep.create_keyspace
|
66
|
+
keyspace.cluster.refresh_schema
|
66
67
|
expect(keyspace).to exist
|
67
68
|
end
|
68
69
|
|
69
70
|
it "causes #sync_schema to fail" do
|
70
|
-
expect{ prep.sync_schema }.to raise_error(
|
71
|
+
expect{ prep.sync_schema }.to raise_error(Cequel::NoSuchKeyspaceError)
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -84,12 +85,18 @@ describe Cequel::SpecSupport::Preparation do
|
|
84
85
|
|
85
86
|
matcher :contain_table do |table_name|
|
86
87
|
match do |keyspace|
|
87
|
-
keyspace.
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
keyspace.cluster.refresh_schema
|
89
|
+
ks = keyspace.cluster.keyspace(keyspace.name)
|
90
|
+
|
91
|
+
ks && ks.has_table?(table_name)
|
92
|
+
end
|
93
|
+
|
94
|
+
failure_message do |keyspace|
|
95
|
+
if keyspace.cluster.has_keyspace?(keyspace.name)
|
96
|
+
"no such keyspace #{keyspace.name}"
|
97
|
+
else
|
98
|
+
"no such table #{keyspace.name}.#{table_name}"
|
99
|
+
end
|
93
100
|
end
|
94
101
|
end
|
95
102
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Brown
|
@@ -29,20 +29,20 @@ authors:
|
|
29
29
|
autorequire:
|
30
30
|
bindir: bin
|
31
31
|
cert_chain: []
|
32
|
-
date: 2016-
|
32
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: activemodel
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '4.0'
|
41
41
|
type: :runtime
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
48
48
|
- !ruby/object:Gem::Dependency
|
@@ -51,14 +51,14 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: appraisal
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -326,7 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
326
|
requirements:
|
327
327
|
- Cassandra >= 2.0.0
|
328
328
|
rubyforge_project:
|
329
|
-
rubygems_version: 2.
|
329
|
+
rubygems_version: 2.5.1
|
330
330
|
signing_key:
|
331
331
|
specification_version: 4
|
332
332
|
summary: Full-featured, ActiveModel-compliant ORM for Cassandra using CQL3
|
@@ -361,4 +361,3 @@ test_files:
|
|
361
361
|
- spec/examples/spec_support/preparation_spec.rb
|
362
362
|
- spec/examples/type_spec.rb
|
363
363
|
- spec/examples/uuids_spec.rb
|
364
|
-
has_rdoc: true
|