cequel 0.5.6 → 1.0.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/cequel.rb +5 -8
- data/lib/cequel/errors.rb +1 -0
- data/lib/cequel/metal.rb +17 -0
- data/lib/cequel/metal/batch.rb +62 -0
- data/lib/cequel/metal/cql_row_specification.rb +26 -0
- data/lib/cequel/metal/data_set.rb +461 -0
- data/lib/cequel/metal/deleter.rb +47 -0
- data/lib/cequel/metal/incrementer.rb +35 -0
- data/lib/cequel/metal/inserter.rb +53 -0
- data/lib/cequel/metal/keyspace.rb +213 -0
- data/lib/cequel/metal/row.rb +48 -0
- data/lib/cequel/metal/row_specification.rb +37 -0
- data/lib/cequel/metal/statement.rb +30 -0
- data/lib/cequel/metal/updater.rb +65 -0
- data/lib/cequel/metal/writer.rb +73 -0
- data/lib/cequel/model.rb +12 -84
- data/lib/cequel/model/association_collection.rb +23 -0
- data/lib/cequel/model/associations.rb +84 -80
- data/lib/cequel/model/base.rb +74 -0
- data/lib/cequel/model/belongs_to_association.rb +31 -0
- data/lib/cequel/model/callbacks.rb +14 -10
- data/lib/cequel/model/collection.rb +255 -0
- data/lib/cequel/model/errors.rb +6 -6
- data/lib/cequel/model/has_many_association.rb +26 -0
- data/lib/cequel/model/mass_assignment.rb +31 -0
- data/lib/cequel/model/persistence.rb +119 -115
- data/lib/cequel/model/properties.rb +89 -87
- data/lib/cequel/model/railtie.rb +21 -14
- data/lib/cequel/model/record_set.rb +285 -0
- data/lib/cequel/model/schema.rb +33 -0
- data/lib/cequel/model/scoped.rb +5 -48
- data/lib/cequel/model/validations.rb +18 -18
- data/lib/cequel/schema.rb +15 -0
- data/lib/cequel/schema/column.rb +135 -0
- data/lib/cequel/schema/create_table_dsl.rb +56 -0
- data/lib/cequel/schema/keyspace.rb +50 -0
- data/lib/cequel/schema/table.rb +120 -0
- data/lib/cequel/schema/table_property.rb +67 -0
- data/lib/cequel/schema/table_reader.rb +139 -0
- data/lib/cequel/schema/table_synchronizer.rb +114 -0
- data/lib/cequel/schema/table_updater.rb +83 -0
- data/lib/cequel/schema/table_writer.rb +80 -0
- data/lib/cequel/schema/update_table_dsl.rb +60 -0
- data/lib/cequel/type.rb +232 -0
- data/lib/cequel/version.rb +1 -1
- data/spec/environment.rb +5 -1
- data/spec/examples/metal/data_set_spec.rb +608 -0
- data/spec/examples/model/associations_spec.rb +84 -74
- data/spec/examples/model/callbacks_spec.rb +66 -59
- data/spec/examples/model/list_spec.rb +393 -0
- data/spec/examples/model/map_spec.rb +229 -0
- data/spec/examples/model/mass_assignment_spec.rb +55 -0
- data/spec/examples/model/naming_spec.rb +11 -4
- data/spec/examples/model/persistence_spec.rb +140 -150
- data/spec/examples/model/properties_spec.rb +122 -75
- data/spec/examples/model/record_set_spec.rb +285 -0
- data/spec/examples/model/schema_spec.rb +44 -0
- data/spec/examples/model/serialization_spec.rb +20 -14
- data/spec/examples/model/set_spec.rb +133 -0
- data/spec/examples/model/spec_helper.rb +0 -10
- data/spec/examples/model/validations_spec.rb +51 -38
- data/spec/examples/schema/table_reader_spec.rb +328 -0
- data/spec/examples/schema/table_synchronizer_spec.rb +172 -0
- data/spec/examples/schema/table_updater_spec.rb +157 -0
- data/spec/examples/schema/table_writer_spec.rb +225 -0
- data/spec/examples/spec_helper.rb +29 -0
- data/spec/examples/type_spec.rb +204 -0
- data/spec/support/helpers.rb +67 -8
- metadata +121 -152
- data/lib/cequel/batch.rb +0 -58
- data/lib/cequel/cql_row_specification.rb +0 -22
- data/lib/cequel/data_set.rb +0 -371
- data/lib/cequel/keyspace.rb +0 -205
- data/lib/cequel/model/class_internals.rb +0 -49
- data/lib/cequel/model/column.rb +0 -20
- data/lib/cequel/model/counter.rb +0 -35
- data/lib/cequel/model/dictionary.rb +0 -126
- data/lib/cequel/model/dirty.rb +0 -53
- data/lib/cequel/model/dynamic.rb +0 -31
- data/lib/cequel/model/inheritable.rb +0 -48
- data/lib/cequel/model/instance_internals.rb +0 -23
- data/lib/cequel/model/local_association.rb +0 -42
- data/lib/cequel/model/magic.rb +0 -79
- data/lib/cequel/model/mass_assignment_security.rb +0 -21
- data/lib/cequel/model/naming.rb +0 -17
- data/lib/cequel/model/observer.rb +0 -42
- data/lib/cequel/model/readable_dictionary.rb +0 -182
- data/lib/cequel/model/remote_association.rb +0 -40
- data/lib/cequel/model/scope.rb +0 -362
- data/lib/cequel/model/subclass_internals.rb +0 -45
- data/lib/cequel/model/timestamps.rb +0 -52
- data/lib/cequel/model/translation.rb +0 -17
- data/lib/cequel/row_specification.rb +0 -63
- data/lib/cequel/statement.rb +0 -23
- data/spec/examples/data_set_spec.rb +0 -444
- data/spec/examples/keyspace_spec.rb +0 -84
- data/spec/examples/model/counter_spec.rb +0 -94
- data/spec/examples/model/dictionary_spec.rb +0 -301
- data/spec/examples/model/dirty_spec.rb +0 -39
- data/spec/examples/model/dynamic_spec.rb +0 -41
- data/spec/examples/model/inheritable_spec.rb +0 -45
- data/spec/examples/model/magic_spec.rb +0 -199
- data/spec/examples/model/mass_assignment_security_spec.rb +0 -13
- data/spec/examples/model/observer_spec.rb +0 -86
- data/spec/examples/model/scope_spec.rb +0 -677
- data/spec/examples/model/timestamps_spec.rb +0 -52
- data/spec/examples/model/translation_spec.rb +0 -23
@@ -0,0 +1,172 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Cequel::Schema::TableSynchronizer do
|
4
|
+
|
5
|
+
let(:table) { cequel.schema.read_table(:posts) }
|
6
|
+
|
7
|
+
context 'with no existing table' do
|
8
|
+
before do
|
9
|
+
cequel.schema.sync_table :posts do
|
10
|
+
key :blog_subdomain, :text
|
11
|
+
key :permalink, :text
|
12
|
+
column :title, :text
|
13
|
+
column :body, :text
|
14
|
+
column :created_at, :timestamp
|
15
|
+
set :author_names, :text
|
16
|
+
with :comment, 'Test Table'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
after { cequel.schema.drop_table(:posts) }
|
21
|
+
|
22
|
+
it 'should create table' do
|
23
|
+
table.column(:title).type.should == Cequel::Type[:text] #etc.
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with an existing table' do
|
28
|
+
before do
|
29
|
+
cequel.schema.create_table :posts do
|
30
|
+
key :blog_subdomain, :text
|
31
|
+
key :permalink, :text
|
32
|
+
column :title, :text, :index => true
|
33
|
+
column :body, :text
|
34
|
+
column :created_at, :timestamp
|
35
|
+
set :author_names, :text
|
36
|
+
with :comment, 'Test Table'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
after { cequel.schema.drop_table(:posts) }
|
41
|
+
|
42
|
+
context 'with valid changes' do
|
43
|
+
|
44
|
+
before do
|
45
|
+
cequel.schema.sync_table :posts do
|
46
|
+
key :blog_subdomain, :text
|
47
|
+
key :post_permalink, :text
|
48
|
+
column :title, :text
|
49
|
+
column :body, :ascii
|
50
|
+
column :primary_author_id, :uuid, :index => true
|
51
|
+
column :created_at, :timestamp, :index => true
|
52
|
+
column :published_at, :timestamp
|
53
|
+
set :author_names, :text
|
54
|
+
list :categories, :text
|
55
|
+
with :comment, 'Test Table 2.0'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should rename keys' do
|
60
|
+
table.clustering_columns.first.name.should == :post_permalink
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should add new columns' do
|
64
|
+
table.column(:published_at).type.should == Cequel::Type[:timestamp]
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should add new collections' do
|
68
|
+
table.column(:categories).should be_a(Cequel::Schema::List)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should add new column with index' do
|
72
|
+
table.column(:primary_author_id).should be_indexed
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should add index to existing columns' do
|
76
|
+
table.column(:created_at).should be_indexed
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should drop index from existing columns' do
|
80
|
+
table.column(:title).should_not be_indexed
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should change column type' do
|
84
|
+
table.column(:body).type.should == Cequel::Type[:ascii]
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should change properties' do
|
88
|
+
table.property(:comment).should == 'Test Table 2.0'
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'invalid migrations' do
|
94
|
+
|
95
|
+
it 'should not allow changing type of key' do
|
96
|
+
expect {
|
97
|
+
cequel.schema.sync_table :posts do
|
98
|
+
key :blog_subdomain, :text
|
99
|
+
key :permalink, :ascii
|
100
|
+
column :title, :text
|
101
|
+
column :body, :text
|
102
|
+
column :created_at, :timestamp
|
103
|
+
set :author_names, :text
|
104
|
+
with :comment, 'Test Table'
|
105
|
+
end
|
106
|
+
}.to raise_error(Cequel::InvalidSchemaMigration)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should not allow adding a key' do
|
110
|
+
expect {
|
111
|
+
cequel.schema.sync_table :posts do
|
112
|
+
key :blog_subdomain, :text
|
113
|
+
key :permalink, :text
|
114
|
+
key :year, :int
|
115
|
+
column :title, :text
|
116
|
+
column :body, :text
|
117
|
+
column :created_at, :timestamp
|
118
|
+
set :author_names, :text
|
119
|
+
with :comment, 'Test Table'
|
120
|
+
end
|
121
|
+
}.to raise_error(Cequel::InvalidSchemaMigration)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should not allow removing a key' do
|
125
|
+
expect {
|
126
|
+
cequel.schema.sync_table :posts do
|
127
|
+
key :blog_subdomain, :text
|
128
|
+
column :title, :text
|
129
|
+
column :body, :text
|
130
|
+
column :created_at, :timestamp
|
131
|
+
set :author_names, :text
|
132
|
+
with :comment, 'Test Table'
|
133
|
+
end
|
134
|
+
}.to raise_error(Cequel::InvalidSchemaMigration)
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should not allow changing the partition status of a key' do
|
138
|
+
expect {
|
139
|
+
cequel.schema.sync_table :posts do
|
140
|
+
key :blog_subdomain, :text
|
141
|
+
partition_key :permalink, :text
|
142
|
+
column :title, :text
|
143
|
+
column :body, :text
|
144
|
+
column :created_at, :timestamp
|
145
|
+
set :author_names, :text
|
146
|
+
with :comment, 'Test Table'
|
147
|
+
end
|
148
|
+
}.to raise_error(Cequel::InvalidSchemaMigration)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should not allow changing the data structure of a column' do
|
152
|
+
expect {
|
153
|
+
cequel.schema.sync_table :posts do
|
154
|
+
key :blog_subdomain, :text
|
155
|
+
key :permalink, :text
|
156
|
+
column :title, :text
|
157
|
+
column :body, :text
|
158
|
+
column :created_at, :timestamp
|
159
|
+
list :author_names, :text
|
160
|
+
with :comment, 'Test Table'
|
161
|
+
end
|
162
|
+
}.to raise_error(Cequel::InvalidSchemaMigration)
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should not allow changing of clustering order'
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Cequel::Schema::TableUpdater do
|
4
|
+
before do
|
5
|
+
cequel.schema.create_table(:posts) do
|
6
|
+
key :blog_subdomain, :text
|
7
|
+
key :permalink, :text
|
8
|
+
column :title, :text
|
9
|
+
column :body, :text
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
after { cequel.schema.drop_table(:posts) }
|
14
|
+
|
15
|
+
let(:table) { cequel.schema.read_table(:posts) }
|
16
|
+
|
17
|
+
describe '#add_column' do
|
18
|
+
before do
|
19
|
+
cequel.schema.alter_table(:posts) do
|
20
|
+
add_column :published_at, :timestamp
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should add the column with the given type' do
|
25
|
+
table.data_column(:published_at).type.should == Cequel::Type[:timestamp]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#add_list' do
|
30
|
+
before do
|
31
|
+
cequel.schema.alter_table(:posts) do
|
32
|
+
add_list :author_names, :text
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should add the list' do
|
37
|
+
table.data_column(:author_names).should be_a(Cequel::Schema::List)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should set the given type' do
|
41
|
+
table.data_column(:author_names).type.should == Cequel::Type[:text]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#add_set' do
|
46
|
+
before do
|
47
|
+
cequel.schema.alter_table(:posts) do
|
48
|
+
add_set :author_names, :text
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should add the list' do
|
53
|
+
table.data_column(:author_names).should be_a(Cequel::Schema::Set)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should set the given type' do
|
57
|
+
table.data_column(:author_names).type.should == Cequel::Type[:text]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#add_map' do
|
62
|
+
before do
|
63
|
+
cequel.schema.alter_table(:posts) do
|
64
|
+
add_map :trackbacks, :timestamp, :ascii
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should add the list' do
|
69
|
+
table.data_column(:trackbacks).should be_a(Cequel::Schema::Map)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should set the key type' do
|
73
|
+
table.data_column(:trackbacks).key_type.
|
74
|
+
should == Cequel::Type[:timestamp]
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should set the value type' do
|
78
|
+
table.data_column(:trackbacks).value_type.
|
79
|
+
should == Cequel::Type[:ascii]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#change_column' do
|
84
|
+
before do
|
85
|
+
cequel.schema.alter_table(:posts) do
|
86
|
+
change_column :title, :ascii
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should change the type' do
|
91
|
+
table.data_column(:title).type.should == Cequel::Type[:ascii]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#rename_column' do
|
96
|
+
before do
|
97
|
+
cequel.schema.alter_table(:posts) do
|
98
|
+
rename_column :permalink, :slug
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should change the name' do
|
103
|
+
table.clustering_column(:slug).should be
|
104
|
+
table.clustering_column(:permalink).should be_nil
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#change_properties' do
|
109
|
+
before do
|
110
|
+
cequel.schema.alter_table(:posts) do
|
111
|
+
change_properties :comment => 'Test Comment'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should change properties' do
|
116
|
+
table.properties[:comment].value.should == 'Test Comment'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#add_index' do
|
121
|
+
before do
|
122
|
+
cequel.schema.alter_table(:posts) do
|
123
|
+
create_index :title
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should add the index' do
|
128
|
+
table.data_column(:title).should be_indexed
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe '#drop_index' do
|
133
|
+
before do
|
134
|
+
cequel.schema.alter_table(:posts) do
|
135
|
+
create_index :title
|
136
|
+
drop_index :posts_title_idx
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should drop the index' do
|
141
|
+
table.data_column(:title).should_not be_indexed
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe '#drop_column' do
|
146
|
+
before do
|
147
|
+
pending 'Support in a future Cassandra version'
|
148
|
+
cequel.schema.alter_table(:posts) do
|
149
|
+
drop_column :body
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should remove the column' do
|
154
|
+
table.data_column(:body).should be_nil
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Cequel::Schema::TableWriter do
|
4
|
+
|
5
|
+
let(:table) { cequel.schema.read_table(:posts) }
|
6
|
+
|
7
|
+
describe '#create_table' do
|
8
|
+
|
9
|
+
after do
|
10
|
+
cequel.schema.drop_table(:posts)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'with simple skinny table' do
|
14
|
+
before do
|
15
|
+
cequel.schema.create_table(:posts) do
|
16
|
+
key :permalink, :ascii
|
17
|
+
column :title, :text
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should create key alias' do
|
22
|
+
table.partition_keys.map(&:name).should == [:permalink]
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should set key validator' do
|
26
|
+
table.partition_keys.map(&:type).should == [Cequel::Type[:ascii]]
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should set non-key columns' do
|
30
|
+
table.columns.find { |column| column.name == :title }.type.
|
31
|
+
should == Cequel::Type[:text]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'with multi-column primary key' do
|
36
|
+
before do
|
37
|
+
cequel.schema.create_table(:posts) do
|
38
|
+
key :blog_subdomain, :ascii
|
39
|
+
key :permalink, :ascii
|
40
|
+
column :title, :text
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should create key alias' do
|
45
|
+
table.partition_keys.map(&:name).should == [:blog_subdomain]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should set key validator' do
|
49
|
+
table.partition_keys.map(&:type).should == [Cequel::Type[:ascii]]
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should create non-partition key components' do
|
53
|
+
table.clustering_columns.map(&:name).should == [:permalink]
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should set type for non-partition key components' do
|
57
|
+
table.clustering_columns.map(&:type).should == [Cequel::Type[:ascii]]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'with composite partition key' do
|
62
|
+
before do
|
63
|
+
cequel.schema.create_table(:posts) do
|
64
|
+
partition_key :blog_subdomain, :ascii
|
65
|
+
partition_key :permalink, :ascii
|
66
|
+
column :title, :text
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should create all partition key components' do
|
71
|
+
table.partition_keys.map(&:name).should == [:blog_subdomain, :permalink]
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should set key validators' do
|
75
|
+
table.partition_keys.map(&:type).
|
76
|
+
should == [Cequel::Type[:ascii], Cequel::Type[:ascii]]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'with composite partition key and non-partition keys' do
|
81
|
+
before do
|
82
|
+
cequel.schema.create_table(:posts) do
|
83
|
+
partition_key :blog_subdomain, :ascii
|
84
|
+
partition_key :permalink, :ascii
|
85
|
+
key :month, :timestamp
|
86
|
+
column :title, :text
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should create all partition key components' do
|
91
|
+
table.partition_keys.map(&:name).
|
92
|
+
should == [:blog_subdomain, :permalink]
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should set key validators' do
|
96
|
+
table.partition_keys.map(&:type).
|
97
|
+
should == [Cequel::Type[:ascii], Cequel::Type[:ascii]]
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should create non-partition key components' do
|
101
|
+
table.clustering_columns.map(&:name).should == [:month]
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should set type for non-partition key components' do
|
105
|
+
table.clustering_columns.map(&:type).should == [Cequel::Type[:timestamp]]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'collection types' do
|
110
|
+
before do
|
111
|
+
cequel.schema.create_table(:posts) do
|
112
|
+
key :permalink, :ascii
|
113
|
+
column :title, :text
|
114
|
+
list :authors, :blob
|
115
|
+
set :tags, :text
|
116
|
+
map :trackbacks, :timestamp, :ascii
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should create list' do
|
121
|
+
table.data_column(:authors).should be_a(Cequel::Schema::List)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should set correct type for list' do
|
125
|
+
table.data_column(:authors).type.should == Cequel::Type[:blob]
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should create set' do
|
129
|
+
table.data_column(:tags).should be_a(Cequel::Schema::Set)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should set correct type for set' do
|
133
|
+
table.data_column(:tags).type.should == Cequel::Type[:text]
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should create map' do
|
137
|
+
table.data_column(:trackbacks).should be_a(Cequel::Schema::Map)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should set correct key type' do
|
141
|
+
table.data_column(:trackbacks).key_type.
|
142
|
+
should == Cequel::Type[:timestamp]
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should set correct value type' do
|
146
|
+
table.data_column(:trackbacks).value_type.
|
147
|
+
should == Cequel::Type[:ascii]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe 'storage properties' do
|
152
|
+
before do
|
153
|
+
cequel.schema.create_table(:posts) do
|
154
|
+
key :permalink, :ascii
|
155
|
+
column :title, :text
|
156
|
+
with :comment, 'Blog posts'
|
157
|
+
with :compression,
|
158
|
+
:sstable_compression => "DeflateCompressor",
|
159
|
+
:chunk_length_kb => 64
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should set simple properties' do
|
164
|
+
table.property(:comment).should == 'Blog posts'
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should set map collection properties' do
|
168
|
+
table.property(:compression).should == {
|
169
|
+
:sstable_compression => 'DeflateCompressor',
|
170
|
+
:chunk_length_kb => 64
|
171
|
+
}
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe 'compact storage' do
|
176
|
+
before do
|
177
|
+
cequel.schema.create_table(:posts) do
|
178
|
+
key :permalink, :ascii
|
179
|
+
column :title, :text
|
180
|
+
compact_storage
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should have compact storage' do
|
185
|
+
table.should be_compact_storage
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe 'clustering order' do
|
190
|
+
before do
|
191
|
+
cequel.schema.create_table(:posts) do
|
192
|
+
key :blog_permalink, :ascii
|
193
|
+
key :id, :uuid, :desc
|
194
|
+
column :title, :text
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should set clustering order' do
|
199
|
+
table.clustering_columns.map(&:clustering_order).should == [:desc]
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe 'indices' do
|
204
|
+
it 'should create indices' do
|
205
|
+
cequel.schema.create_table(:posts) do
|
206
|
+
key :blog_permalink, :ascii
|
207
|
+
key :id, :uuid, :desc
|
208
|
+
column :title, :text, :index => true
|
209
|
+
end
|
210
|
+
table.data_column(:title).should be_indexed
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should create indices with specified name' do
|
214
|
+
cequel.schema.create_table(:posts) do
|
215
|
+
key :blog_permalink, :ascii
|
216
|
+
key :id, :uuid, :desc
|
217
|
+
column :title, :text, :index => :silly_idx
|
218
|
+
end
|
219
|
+
table.data_column(:title).index_name.should == :silly_idx
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|