cequel 1.7.0 → 1.8.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 +8 -0
- data/Gemfile.lock +64 -75
- data/README.md +32 -4
- data/Rakefile +8 -7
- data/lib/cequel/metal/data_set.rb +29 -4
- data/lib/cequel/metal/keyspace.rb +18 -14
- data/lib/cequel/metal/request_logger.rb +7 -0
- data/lib/cequel/record/data_set_builder.rb +15 -1
- data/lib/cequel/record/properties.rb +2 -0
- data/lib/cequel/record/record_set.rb +28 -2
- data/lib/cequel/schema/table_reader.rb +1 -1
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/metal/data_set_spec.rb +24 -0
- data/spec/examples/record/dirty_spec.rb +0 -8
- data/spec/examples/record/persistence_spec.rb +2 -2
- data/spec/examples/record/properties_spec.rb +5 -0
- data/spec/examples/record/record_set_spec.rb +35 -0
- data/spec/examples/record/schema_spec.rb +42 -0
- data/spec/examples/schema/table_reader_spec.rb +16 -15
- data/spec/examples/schema/table_synchronizer_spec.rb +14 -13
- data/spec/examples/schema/table_updater_spec.rb +23 -20
- data/spec/examples/schema/table_writer_spec.rb +13 -12
- data/spec/examples/spec_support/preparation_spec.rb +8 -0
- data/spec/support/helpers.rb +8 -0
- metadata +3 -6
- data/DRIVER_TODO +0 -5
- data/cequel.gemspec +0 -42
- data/tags +0 -836
@@ -2,12 +2,13 @@
|
|
2
2
|
require File.expand_path('../../spec_helper', __FILE__)
|
3
3
|
|
4
4
|
describe Cequel::Schema::TableSynchronizer do
|
5
|
+
let(:table_name) { :"posts_#{SecureRandom.hex(4)}" }
|
5
6
|
|
6
|
-
let(:table) { cequel.schema.read_table(
|
7
|
+
let(:table) { cequel.schema.read_table(table_name) }
|
7
8
|
|
8
9
|
context 'with no existing table' do
|
9
10
|
before do
|
10
|
-
cequel.schema.sync_table
|
11
|
+
cequel.schema.sync_table table_name do
|
11
12
|
key :blog_subdomain, :text
|
12
13
|
key :permalink, :text
|
13
14
|
column :title, :text
|
@@ -18,7 +19,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
after { cequel.schema.drop_table(
|
22
|
+
after { cequel.schema.drop_table(table_name) }
|
22
23
|
|
23
24
|
it 'should create table' do
|
24
25
|
expect(table.column(:title).type).to eq(Cequel::Type[:text]) #etc.
|
@@ -27,7 +28,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
27
28
|
|
28
29
|
context 'with an existing table' do
|
29
30
|
before do
|
30
|
-
cequel.schema.create_table
|
31
|
+
cequel.schema.create_table table_name do
|
31
32
|
key :blog_subdomain, :text
|
32
33
|
key :permalink, :text
|
33
34
|
column :title, :ascii, :index => true
|
@@ -38,12 +39,12 @@ describe Cequel::Schema::TableSynchronizer do
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
after { cequel.schema.drop_table(
|
42
|
+
after { cequel.schema.drop_table(table_name) }
|
42
43
|
|
43
44
|
context 'with valid changes' do
|
44
45
|
|
45
46
|
before do
|
46
|
-
cequel.schema.sync_table
|
47
|
+
cequel.schema.sync_table table_name do
|
47
48
|
key :blog_subdomain, :text
|
48
49
|
key :post_permalink, :text
|
49
50
|
column :title, :ascii
|
@@ -95,7 +96,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
95
96
|
|
96
97
|
it 'should not allow changing type of key' do
|
97
98
|
expect {
|
98
|
-
cequel.schema.sync_table
|
99
|
+
cequel.schema.sync_table table_name do
|
99
100
|
key :blog_subdomain, :text
|
100
101
|
key :permalink, :ascii
|
101
102
|
column :title, :ascii
|
@@ -109,7 +110,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
109
110
|
|
110
111
|
it 'should not allow adding a key' do
|
111
112
|
expect {
|
112
|
-
cequel.schema.sync_table
|
113
|
+
cequel.schema.sync_table table_name do
|
113
114
|
key :blog_subdomain, :text
|
114
115
|
key :permalink, :text
|
115
116
|
key :year, :int
|
@@ -124,7 +125,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
124
125
|
|
125
126
|
it 'should not allow removing a key' do
|
126
127
|
expect {
|
127
|
-
cequel.schema.sync_table
|
128
|
+
cequel.schema.sync_table table_name do
|
128
129
|
key :blog_subdomain, :text
|
129
130
|
column :title, :ascii
|
130
131
|
column :body, :text
|
@@ -137,7 +138,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
137
138
|
|
138
139
|
it 'should not allow changing the partition status of a key' do
|
139
140
|
expect {
|
140
|
-
cequel.schema.sync_table
|
141
|
+
cequel.schema.sync_table table_name do
|
141
142
|
key :blog_subdomain, :text
|
142
143
|
partition_key :permalink, :text
|
143
144
|
column :title, :ascii
|
@@ -151,7 +152,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
151
152
|
|
152
153
|
it 'should not allow changing the data structure of a column' do
|
153
154
|
expect {
|
154
|
-
cequel.schema.sync_table
|
155
|
+
cequel.schema.sync_table table_name do
|
155
156
|
key :blog_subdomain, :text
|
156
157
|
key :permalink, :text
|
157
158
|
column :title, :ascii
|
@@ -165,7 +166,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
165
166
|
|
166
167
|
it 'should not allow invalid type transitions of a data column' do
|
167
168
|
expect {
|
168
|
-
cequel.schema.sync_table
|
169
|
+
cequel.schema.sync_table table_name do
|
169
170
|
key :blog_subdomain, :text
|
170
171
|
key :permalink, :text
|
171
172
|
column :title, :ascii, :index => true
|
@@ -179,7 +180,7 @@ describe Cequel::Schema::TableSynchronizer do
|
|
179
180
|
|
180
181
|
it 'should not allow changing clustering order' do
|
181
182
|
expect {
|
182
|
-
cequel.schema.sync_table
|
183
|
+
cequel.schema.sync_table table_name do
|
183
184
|
key :blog_subdomain, :text
|
184
185
|
key :permalink, :text, :desc
|
185
186
|
column :title, :ascii, :index => true
|
@@ -2,8 +2,10 @@
|
|
2
2
|
require File.expand_path('../../spec_helper', __FILE__)
|
3
3
|
|
4
4
|
describe Cequel::Schema::TableUpdater do
|
5
|
+
let(:table_name) { :"posts_#{SecureRandom.hex(4)}" }
|
6
|
+
|
5
7
|
before do
|
6
|
-
cequel.schema.create_table(
|
8
|
+
cequel.schema.create_table(table_name) do
|
7
9
|
key :blog_subdomain, :text
|
8
10
|
key :permalink, :text
|
9
11
|
column :title, :ascii
|
@@ -11,13 +13,13 @@ describe Cequel::Schema::TableUpdater do
|
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
after { cequel.schema.drop_table(
|
16
|
+
after { cequel.schema.drop_table(table_name) }
|
15
17
|
|
16
|
-
let(:table) { cequel.schema.read_table(
|
18
|
+
let(:table) { cequel.schema.read_table(table_name) }
|
17
19
|
|
18
20
|
describe '#add_column' do
|
19
21
|
before do
|
20
|
-
cequel.schema.alter_table(
|
22
|
+
cequel.schema.alter_table(table_name) do
|
21
23
|
add_column :published_at, :timestamp
|
22
24
|
end
|
23
25
|
end
|
@@ -29,7 +31,7 @@ describe Cequel::Schema::TableUpdater do
|
|
29
31
|
|
30
32
|
describe '#add_list' do
|
31
33
|
before do
|
32
|
-
cequel.schema.alter_table(
|
34
|
+
cequel.schema.alter_table(table_name) do
|
33
35
|
add_list :author_names, :text
|
34
36
|
end
|
35
37
|
end
|
@@ -45,7 +47,7 @@ describe Cequel::Schema::TableUpdater do
|
|
45
47
|
|
46
48
|
describe '#add_set' do
|
47
49
|
before do
|
48
|
-
cequel.schema.alter_table(
|
50
|
+
cequel.schema.alter_table(table_name) do
|
49
51
|
add_set :author_names, :text
|
50
52
|
end
|
51
53
|
end
|
@@ -61,7 +63,7 @@ describe Cequel::Schema::TableUpdater do
|
|
61
63
|
|
62
64
|
describe '#add_map' do
|
63
65
|
before do
|
64
|
-
cequel.schema.alter_table(
|
66
|
+
cequel.schema.alter_table(table_name) do
|
65
67
|
add_map :trackbacks, :timestamp, :ascii
|
66
68
|
end
|
67
69
|
end
|
@@ -83,7 +85,7 @@ describe Cequel::Schema::TableUpdater do
|
|
83
85
|
|
84
86
|
describe '#change_column' do
|
85
87
|
before do
|
86
|
-
cequel.schema.alter_table(
|
88
|
+
cequel.schema.alter_table(table_name) do
|
87
89
|
change_column :title, :text
|
88
90
|
end
|
89
91
|
end
|
@@ -95,7 +97,7 @@ describe Cequel::Schema::TableUpdater do
|
|
95
97
|
|
96
98
|
describe '#rename_column' do
|
97
99
|
before do
|
98
|
-
cequel.schema.alter_table(
|
100
|
+
cequel.schema.alter_table(table_name) do
|
99
101
|
rename_column :permalink, :slug
|
100
102
|
end
|
101
103
|
end
|
@@ -108,7 +110,7 @@ describe Cequel::Schema::TableUpdater do
|
|
108
110
|
|
109
111
|
describe '#change_properties' do
|
110
112
|
before do
|
111
|
-
cequel.schema.alter_table(
|
113
|
+
cequel.schema.alter_table(table_name) do
|
112
114
|
change_properties :comment => 'Test Comment'
|
113
115
|
end
|
114
116
|
end
|
@@ -118,35 +120,36 @@ describe Cequel::Schema::TableUpdater do
|
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
121
|
-
describe '#
|
123
|
+
describe '#drop_index' do
|
122
124
|
before do
|
123
|
-
|
125
|
+
tab_name = table_name
|
126
|
+
cequel.schema.alter_table(table_name) do
|
124
127
|
create_index :title
|
128
|
+
drop_index :"#{tab_name}_title_idx"
|
125
129
|
end
|
126
130
|
end
|
127
131
|
|
128
|
-
it 'should
|
129
|
-
expect(table.data_column(:title)).
|
132
|
+
it 'should drop the index' do
|
133
|
+
expect(table.data_column(:title)).not_to be_indexed
|
130
134
|
end
|
131
135
|
end
|
132
136
|
|
133
|
-
describe '#
|
137
|
+
describe '#add_index' do
|
134
138
|
before do
|
135
|
-
cequel.schema.alter_table(
|
139
|
+
cequel.schema.alter_table(table_name) do
|
136
140
|
create_index :title
|
137
|
-
drop_index :posts_title_idx
|
138
141
|
end
|
139
142
|
end
|
140
143
|
|
141
|
-
it 'should
|
142
|
-
expect(table.data_column(:title)).
|
144
|
+
it 'should add the index' do
|
145
|
+
expect(table.data_column(:title)).to be_indexed
|
143
146
|
end
|
144
147
|
end
|
145
148
|
|
146
149
|
describe '#drop_column' do
|
147
150
|
before do
|
148
151
|
pending 'Support in a future Cassandra version'
|
149
|
-
cequel.schema.alter_table(
|
152
|
+
cequel.schema.alter_table(table_name) do
|
150
153
|
drop_column :body
|
151
154
|
end
|
152
155
|
end
|
@@ -2,18 +2,19 @@
|
|
2
2
|
require File.expand_path('../../spec_helper', __FILE__)
|
3
3
|
|
4
4
|
describe Cequel::Schema::TableWriter do
|
5
|
+
let(:table_name) { :"posts_#{SecureRandom.hex(4)}" }
|
5
6
|
|
6
|
-
let(:table) { cequel.schema.read_table(
|
7
|
+
let(:table) { cequel.schema.read_table(table_name) }
|
7
8
|
|
8
9
|
describe '#create_table' do
|
9
10
|
|
10
11
|
after do
|
11
|
-
cequel.schema.drop_table(
|
12
|
+
cequel.schema.drop_table(table_name)
|
12
13
|
end
|
13
14
|
|
14
15
|
describe 'with simple skinny table' do
|
15
16
|
before do
|
16
|
-
cequel.schema.create_table(
|
17
|
+
cequel.schema.create_table(table_name) do
|
17
18
|
key :permalink, :ascii
|
18
19
|
column :title, :text
|
19
20
|
end
|
@@ -35,7 +36,7 @@ describe Cequel::Schema::TableWriter do
|
|
35
36
|
|
36
37
|
describe 'with multi-column primary key' do
|
37
38
|
before do
|
38
|
-
cequel.schema.create_table(
|
39
|
+
cequel.schema.create_table(table_name) do
|
39
40
|
key :blog_subdomain, :ascii
|
40
41
|
key :permalink, :ascii
|
41
42
|
column :title, :text
|
@@ -61,7 +62,7 @@ describe Cequel::Schema::TableWriter do
|
|
61
62
|
|
62
63
|
describe 'with composite partition key' do
|
63
64
|
before do
|
64
|
-
cequel.schema.create_table(
|
65
|
+
cequel.schema.create_table(table_name) do
|
65
66
|
partition_key :blog_subdomain, :ascii
|
66
67
|
partition_key :permalink, :ascii
|
67
68
|
column :title, :text
|
@@ -80,7 +81,7 @@ describe Cequel::Schema::TableWriter do
|
|
80
81
|
|
81
82
|
describe 'with composite partition key and non-partition keys' do
|
82
83
|
before do
|
83
|
-
cequel.schema.create_table(
|
84
|
+
cequel.schema.create_table(table_name) do
|
84
85
|
partition_key :blog_subdomain, :ascii
|
85
86
|
partition_key :permalink, :ascii
|
86
87
|
key :month, :timestamp
|
@@ -109,7 +110,7 @@ describe Cequel::Schema::TableWriter do
|
|
109
110
|
|
110
111
|
describe 'collection types' do
|
111
112
|
before do
|
112
|
-
cequel.schema.create_table(
|
113
|
+
cequel.schema.create_table(table_name) do
|
113
114
|
key :permalink, :ascii
|
114
115
|
column :title, :text
|
115
116
|
list :authors, :blob
|
@@ -151,7 +152,7 @@ describe Cequel::Schema::TableWriter do
|
|
151
152
|
|
152
153
|
describe 'storage properties' do
|
153
154
|
before do
|
154
|
-
cequel.schema.create_table(
|
155
|
+
cequel.schema.create_table(table_name) do
|
155
156
|
key :permalink, :ascii
|
156
157
|
column :title, :text
|
157
158
|
with :comment, 'Blog posts'
|
@@ -175,7 +176,7 @@ describe Cequel::Schema::TableWriter do
|
|
175
176
|
|
176
177
|
describe 'compact storage' do
|
177
178
|
before do
|
178
|
-
cequel.schema.create_table(
|
179
|
+
cequel.schema.create_table(table_name) do
|
179
180
|
key :permalink, :ascii
|
180
181
|
column :title, :text
|
181
182
|
compact_storage
|
@@ -189,7 +190,7 @@ describe Cequel::Schema::TableWriter do
|
|
189
190
|
|
190
191
|
describe 'clustering order' do
|
191
192
|
before do
|
192
|
-
cequel.schema.create_table(
|
193
|
+
cequel.schema.create_table(table_name) do
|
193
194
|
key :blog_permalink, :ascii
|
194
195
|
key :id, :uuid, :desc
|
195
196
|
column :title, :text
|
@@ -203,7 +204,7 @@ describe Cequel::Schema::TableWriter do
|
|
203
204
|
|
204
205
|
describe 'indices' do
|
205
206
|
it 'should create indices' do
|
206
|
-
cequel.schema.create_table(
|
207
|
+
cequel.schema.create_table(table_name) do
|
207
208
|
key :blog_permalink, :ascii
|
208
209
|
key :id, :uuid, :desc
|
209
210
|
column :title, :text, :index => true
|
@@ -212,7 +213,7 @@ describe Cequel::Schema::TableWriter do
|
|
212
213
|
end
|
213
214
|
|
214
215
|
it 'should create indices with specified name' do
|
215
|
-
cequel.schema.create_table(
|
216
|
+
cequel.schema.create_table(table_name) do
|
216
217
|
key :blog_permalink, :ascii
|
217
218
|
key :id, :uuid, :desc
|
218
219
|
column :title, :text, :index => :silly_idx
|
@@ -49,6 +49,14 @@ describe Cequel::SpecSupport::Preparation do
|
|
49
49
|
Cequel::Record.connection.schema.drop!
|
50
50
|
end
|
51
51
|
|
52
|
+
let!(:model) {
|
53
|
+
Class.new do
|
54
|
+
include Cequel::Record
|
55
|
+
self.table_name = "blog_" + SecureRandom.hex(4)
|
56
|
+
key :name, :text
|
57
|
+
end
|
58
|
+
}
|
59
|
+
|
52
60
|
it "doesn't cause failure upon drop requests" do
|
53
61
|
expect{ prep.drop_keyspace }.not_to raise_error
|
54
62
|
end
|
data/spec/support/helpers.rb
CHANGED
@@ -139,6 +139,14 @@ module Cequel
|
|
139
139
|
expect(cequel.client).to have_received(:execute).
|
140
140
|
with(matcher, hash_including(:consistency => consistency))
|
141
141
|
end
|
142
|
+
|
143
|
+
def expect_query_with_options(matcher, options)
|
144
|
+
allow(cequel.client).to receive(:execute).and_call_original
|
145
|
+
yield
|
146
|
+
expect(cequel.client).to have_received(:execute).
|
147
|
+
with(matcher, hash_including(options))
|
148
|
+
end
|
149
|
+
|
142
150
|
end
|
143
151
|
end
|
144
152
|
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: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Brown
|
@@ -29,7 +29,7 @@ authors:
|
|
29
29
|
autorequire:
|
30
30
|
bindir: bin
|
31
31
|
cert_chain: []
|
32
|
-
date:
|
32
|
+
date: 2016-03-27 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: activemodel
|
@@ -199,14 +199,12 @@ files:
|
|
199
199
|
- Appraisals
|
200
200
|
- CHANGELOG.md
|
201
201
|
- CONTRIBUTING.md
|
202
|
-
- DRIVER_TODO
|
203
202
|
- Gemfile
|
204
203
|
- Gemfile.lock
|
205
204
|
- LICENSE
|
206
205
|
- README.md
|
207
206
|
- Rakefile
|
208
207
|
- Vagrantfile
|
209
|
-
- cequel.gemspec
|
210
208
|
- lib/cequel.rb
|
211
209
|
- lib/cequel/errors.rb
|
212
210
|
- lib/cequel/instrumentation.rb
|
@@ -304,7 +302,6 @@ files:
|
|
304
302
|
- spec/examples/uuids_spec.rb
|
305
303
|
- spec/support/helpers.rb
|
306
304
|
- spec/support/result_stub.rb
|
307
|
-
- tags
|
308
305
|
- templates/config/cequel.yml
|
309
306
|
- templates/record.rb
|
310
307
|
homepage: https://github.com/cequel/cequel
|
@@ -328,7 +325,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
328
325
|
requirements:
|
329
326
|
- Cassandra >= 2.0.0
|
330
327
|
rubyforge_project:
|
331
|
-
rubygems_version: 2.
|
328
|
+
rubygems_version: 2.2.5
|
332
329
|
signing_key:
|
333
330
|
specification_version: 4
|
334
331
|
summary: Full-featured, ActiveModel-compliant ORM for Cassandra using CQL3
|
data/DRIVER_TODO
DELETED
data/cequel.gemspec
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require File.expand_path('../lib/cequel/version', __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'cequel'
|
5
|
-
s.version = Cequel::VERSION
|
6
|
-
s.authors = [
|
7
|
-
'Mat Brown', 'Aubrey Holland', 'Keenan Brock', 'Insoo Buzz Jung',
|
8
|
-
'Louis Simoneau', 'Peter Williams', 'Kenneth Hoffman', 'Antti Tapio',
|
9
|
-
'Ilya Bazylchuk', 'Dan Cardamore', 'Kei Kusakari', 'Oleh Novosad',
|
10
|
-
'John Smart', 'Angelo Lakra', 'Olivier Lance', 'Tomohiro Nishimura',
|
11
|
-
'Masaki Takahashi', 'G Gordon Worley III', 'Clark Bremer', 'Tamara Temple',
|
12
|
-
'Long On', 'Lucas Mundim'
|
13
|
-
]
|
14
|
-
s.homepage = "https://github.com/cequel/cequel"
|
15
|
-
s.email = 'mat.a.brown@gmail.com'
|
16
|
-
s.license = 'MIT'
|
17
|
-
s.summary = 'Full-featured, ActiveModel-compliant ORM for Cassandra using CQL3'
|
18
|
-
s.description = <<DESC
|
19
|
-
Cequel is an ActiveRecord-like domain model layer for Cassandra that exposes
|
20
|
-
the robust data modeling capabilities of CQL3, including parent-child
|
21
|
-
relationships via compound primary keys and in-memory atomic manipulation of
|
22
|
-
collection columns.
|
23
|
-
DESC
|
24
|
-
|
25
|
-
s.files = Dir['lib/**/*.rb', 'templates/**/*', 'spec/**/*.rb', '[A-Z]*']
|
26
|
-
s.test_files = Dir['spec/examples/**/*.rb']
|
27
|
-
s.has_rdoc = true
|
28
|
-
s.extra_rdoc_files = 'README.md'
|
29
|
-
s.required_ruby_version = '>= 2.0'
|
30
|
-
s.add_runtime_dependency 'activemodel', '~> 4.0'
|
31
|
-
s.add_runtime_dependency 'cassandra-driver', '~> 2.0'
|
32
|
-
s.add_development_dependency 'appraisal', '~> 1.0'
|
33
|
-
s.add_development_dependency 'wwtd', '~> 0.5'
|
34
|
-
s.add_development_dependency 'rake', '~> 10.1'
|
35
|
-
s.add_development_dependency 'rspec', '~> 3.1'
|
36
|
-
s.add_development_dependency 'rspec-its', '~> 1.0'
|
37
|
-
s.add_development_dependency 'rubocop', '~> 0.28'
|
38
|
-
s.add_development_dependency 'timecop', '~> 0.7'
|
39
|
-
s.add_development_dependency 'travis', '~> 1.7'
|
40
|
-
s.add_development_dependency 'yard', '~> 0.6'
|
41
|
-
s.requirements << 'Cassandra >= 2.0.0'
|
42
|
-
end
|