cequel 1.6.1 → 1.7.0
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +9 -12
- data/README.md +5 -7
- data/Rakefile +0 -1
- data/Vagrantfile +1 -1
- data/cequel.gemspec +4 -4
- data/lib/cequel/metal/keyspace.rb +25 -0
- data/lib/cequel/record/record_set.rb +18 -0
- data/lib/cequel/record/tasks.rb +30 -7
- data/lib/cequel/schema/table_reader.rb +41 -15
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/metal/data_set_spec.rb +1 -1
- data/spec/examples/metal/keyspace_spec.rb +18 -0
- data/spec/examples/record/record_set_spec.rb +48 -11
- data/spec/examples/schema/keyspace_spec.rb +2 -2
- data/spec/examples/spec_helper.rb +1 -0
- data/spec/examples/spec_support/preparation_spec.rb +10 -5
- metadata +10 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14904f7678b99fb9228f1d0e255ece706ac607f
|
4
|
+
data.tar.gz: 9f63a0b4abf6d672c9712d7e5eebe34aae777212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbad8d78bc4b5752cd0a708948c6f95fa0145679a3d8748ca16084e15b11b6c820817a244083d357799fc05c44c188dfe5703b22527ab1c3de5e36522418eb5c
|
7
|
+
data.tar.gz: c0eaaa9c567b14710dbd73bf58c6fe8ff27bec66b99545a362017206839c5f88c4de146500b50c97fc3c776041534fb1517107bed4e43d69472b7fb3d1ba82ac
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 1.7.0
|
2
|
+
|
3
|
+
* Support Cassandra up to 2.2
|
4
|
+
* Support JRuby 9
|
5
|
+
* Drop support for Rails 3, Ruby 1.9
|
6
|
+
* Update to `cassandra-driver` 2.0
|
7
|
+
* Support SSL configuration
|
8
|
+
* Add `RecordSet#first_or_initialize` and `RecordSet#first!`
|
9
|
+
* Rake task to reset keyspace
|
10
|
+
|
1
11
|
## 1.6.1
|
2
12
|
|
3
13
|
* Ruby 1.9 no longer supported (EOL)
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cequel (1.
|
5
|
-
activemodel (
|
6
|
-
cassandra-driver (~>
|
4
|
+
cequel (1.7.0)
|
5
|
+
activemodel (~> 4.0)
|
6
|
+
cassandra-driver (~> 2.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (4.2.
|
12
|
-
activesupport (= 4.2.
|
11
|
+
activemodel (4.2.4)
|
12
|
+
activesupport (= 4.2.4)
|
13
13
|
builder (~> 3.1)
|
14
|
-
activesupport (4.2.
|
14
|
+
activesupport (4.2.4)
|
15
15
|
i18n (~> 0.7)
|
16
16
|
json (~> 1.7, >= 1.7.7)
|
17
17
|
minitest (~> 5.1)
|
@@ -30,9 +30,7 @@ GEM
|
|
30
30
|
byebug (2.7.0)
|
31
31
|
columnize (~> 0.3)
|
32
32
|
debugger-linecache (~> 1.2)
|
33
|
-
cassandra-driver (1.
|
34
|
-
ione (~> 1.2)
|
35
|
-
cassandra-driver (1.2.0-java)
|
33
|
+
cassandra-driver (2.1.4)
|
36
34
|
ione (~> 1.2)
|
37
35
|
coderay (1.1.0)
|
38
36
|
columnize (0.9.0)
|
@@ -61,7 +59,7 @@ GEM
|
|
61
59
|
net-http-pipeline
|
62
60
|
highline (1.6.21)
|
63
61
|
i18n (0.7.0)
|
64
|
-
ione (1.2.
|
62
|
+
ione (1.2.1)
|
65
63
|
json (1.8.2)
|
66
64
|
json (1.8.2-java)
|
67
65
|
launchy (2.4.3)
|
@@ -70,7 +68,7 @@ GEM
|
|
70
68
|
addressable (~> 2.3)
|
71
69
|
spoon (~> 0.0.1)
|
72
70
|
method_source (0.8.2)
|
73
|
-
minitest (5.
|
71
|
+
minitest (5.8.0)
|
74
72
|
multi_json (1.10.1)
|
75
73
|
multipart-post (2.0.0)
|
76
74
|
net-http-persistent (2.9.4)
|
@@ -321,7 +319,6 @@ GEM
|
|
321
319
|
ffi
|
322
320
|
thor (0.19.1)
|
323
321
|
thread_safe (0.3.5)
|
324
|
-
thread_safe (0.3.5-java)
|
325
322
|
timecop (0.7.1)
|
326
323
|
travis (1.7.5)
|
327
324
|
addressable (~> 2.3)
|
data/README.md
CHANGED
@@ -337,7 +337,7 @@ Post.find_all_by_author_id(id) # returns an array of all posts with that author_
|
|
337
337
|
You can also call the `where` method directly on record sets:
|
338
338
|
|
339
339
|
```ruby
|
340
|
-
Post.where(:
|
340
|
+
Post.where(author_id: id)
|
341
341
|
```
|
342
342
|
|
343
343
|
### Consistency tuning ###
|
@@ -516,21 +516,19 @@ the columns that are given.
|
|
516
516
|
* 4.2
|
517
517
|
* 4.1
|
518
518
|
* 4.0
|
519
|
-
* 3.2
|
520
519
|
|
521
520
|
### Ruby ###
|
522
521
|
|
523
522
|
* Ruby 2.2, 2.1, 2.0
|
524
|
-
* JRuby 1.7
|
523
|
+
* JRuby 1.7, 9.0
|
525
524
|
* Rubinius 2.5
|
526
525
|
|
527
526
|
### Cassandra ###
|
528
527
|
|
529
|
-
*
|
530
|
-
* 2.0
|
528
|
+
* 2.x
|
531
529
|
|
532
|
-
Though Cequel is tested against Cassandra 2
|
533
|
-
any of the CQL3.1 features introduced in Cassandra 2.
|
530
|
+
Though Cequel is tested against Cassandra 2, it does not at this time support
|
531
|
+
any of the CQL3.1 features introduced in Cassandra 2. This will change in the
|
534
532
|
future.
|
535
533
|
|
536
534
|
## Support & Bugs ##
|
data/Rakefile
CHANGED
data/Vagrantfile
CHANGED
@@ -135,7 +135,7 @@ exec /opt/apache-cassandra-$1/bin/cassandra" > /etc/init/cassandra.conf
|
|
135
135
|
SH
|
136
136
|
|
137
137
|
versions = File.read(File.expand_path('../.cassandra-versions', __FILE__)).each_line
|
138
|
-
.map(&:strip).grep(/^
|
138
|
+
.map(&:strip).grep(/^2\./)
|
139
139
|
versions.each do |version|
|
140
140
|
java_version = version =~ /^1/ ? '6' : '7'
|
141
141
|
config.vm.define version do |machine|
|
data/cequel.gemspec
CHANGED
@@ -26,9 +26,9 @@ DESC
|
|
26
26
|
s.test_files = Dir['spec/examples/**/*.rb']
|
27
27
|
s.has_rdoc = true
|
28
28
|
s.extra_rdoc_files = 'README.md'
|
29
|
-
s.required_ruby_version = '>=
|
30
|
-
s.add_runtime_dependency 'activemodel', '
|
31
|
-
s.add_runtime_dependency 'cassandra-driver', '~>
|
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
32
|
s.add_development_dependency 'appraisal', '~> 1.0'
|
33
33
|
s.add_development_dependency 'wwtd', '~> 0.5'
|
34
34
|
s.add_development_dependency 'rake', '~> 10.1'
|
@@ -38,5 +38,5 @@ DESC
|
|
38
38
|
s.add_development_dependency 'timecop', '~> 0.7'
|
39
39
|
s.add_development_dependency 'travis', '~> 1.7'
|
40
40
|
s.add_development_dependency 'yard', '~> 0.6'
|
41
|
-
s.requirements << 'Cassandra >=
|
41
|
+
s.requirements << 'Cassandra >= 2.0.0'
|
42
42
|
end
|
@@ -30,6 +30,8 @@ module Cequel
|
|
30
30
|
attr_writer :default_consistency
|
31
31
|
# @return [Hash] credentials for connect to cassandra
|
32
32
|
attr_reader :credentials
|
33
|
+
# @return [Hash] SSL Configuration options
|
34
|
+
attr_reader :ssl_config
|
33
35
|
|
34
36
|
#
|
35
37
|
# @!method write(statement, *bind_vars)
|
@@ -111,6 +113,15 @@ module Cequel
|
|
111
113
|
# @option configuration [String] :password password to auth with (leave
|
112
114
|
# blank for no auth)
|
113
115
|
# @option configuration [String] :keyspace name of keyspace to connect to
|
116
|
+
# @option configuration [Boolean] :ssl enable/disable ssl/tls support
|
117
|
+
# @option configuration [String] :server_cert path to ssl server
|
118
|
+
# certificate
|
119
|
+
# @option configuration [String] :client_cert path to ssl client
|
120
|
+
# certificate
|
121
|
+
# @option configuration [String] :private_key path to ssl client private
|
122
|
+
# key
|
123
|
+
# @option configuartion [String] :passphrase the passphrase for client
|
124
|
+
# private key
|
114
125
|
# @return [void]
|
115
126
|
#
|
116
127
|
def configure(configuration = {})
|
@@ -124,6 +135,7 @@ module Cequel
|
|
124
135
|
@credentials = extract_credentials(configuration)
|
125
136
|
@max_retries = extract_max_retries(configuration)
|
126
137
|
@retry_delay = extract_retry_delay(configuration)
|
138
|
+
@ssl_config = extract_ssl_config(configuration)
|
127
139
|
|
128
140
|
@name = configuration[:keyspace]
|
129
141
|
@default_consistency = configuration[:default_consistency].try(:to_sym)
|
@@ -216,6 +228,7 @@ module Cequel
|
|
216
228
|
remove_instance_variable(:@client_without_keyspace)
|
217
229
|
end
|
218
230
|
if defined? @cluster
|
231
|
+
@cluster.close
|
219
232
|
remove_instance_variable(:@cluster)
|
220
233
|
end
|
221
234
|
end
|
@@ -266,6 +279,7 @@ module Cequel
|
|
266
279
|
def client_options
|
267
280
|
{hosts: hosts, port: port}.tap do |options|
|
268
281
|
options.merge!(credentials) if credentials
|
282
|
+
options.merge!(ssl_config) if ssl_config
|
269
283
|
end
|
270
284
|
end
|
271
285
|
|
@@ -312,6 +326,17 @@ module Cequel
|
|
312
326
|
def extract_retry_delay(configuration)
|
313
327
|
configuration.fetch(:retry_delay, 0.5)
|
314
328
|
end
|
329
|
+
|
330
|
+
def extract_ssl_config(configuration)
|
331
|
+
ssl_config = {}
|
332
|
+
ssl_config[:ssl] = configuration.fetch(:ssl, nil)
|
333
|
+
ssl_config[:server_cert] = configuration.fetch(:server_cert, nil)
|
334
|
+
ssl_config[:client_cert] = configuration.fetch(:client_cert, nil)
|
335
|
+
ssl_config[:private_key] = configuration.fetch(:private_key, nil)
|
336
|
+
ssl_config[:passphrase] = configuration.fetch(:passphrase, nil)
|
337
|
+
ssl_config.each { |key, value| ssl_config.delete(key) unless value }
|
338
|
+
ssl_config
|
339
|
+
end
|
315
340
|
end
|
316
341
|
end
|
317
342
|
end
|
@@ -478,6 +478,24 @@ module Cequel
|
|
478
478
|
count ? limit(count).entries : limit(1).each.first
|
479
479
|
end
|
480
480
|
|
481
|
+
#
|
482
|
+
# @return [Record] the first record or a new instance
|
483
|
+
#
|
484
|
+
def first_or_initialize
|
485
|
+
first || new
|
486
|
+
end
|
487
|
+
|
488
|
+
#
|
489
|
+
# @return [Record] the first record
|
490
|
+
# @raise [RecordNotFound] if the record set is empty
|
491
|
+
#
|
492
|
+
def first!
|
493
|
+
first or fail(RecordNotFound,
|
494
|
+
"Couldn't find record with keys: #{
|
495
|
+
scoped_key_attributes.map { |k, v|
|
496
|
+
"#{k}: #{v}" }.join(', ')}")
|
497
|
+
end
|
498
|
+
|
481
499
|
#
|
482
500
|
# @overload last
|
483
501
|
# @return [Record] the last record in this record set
|
data/lib/cequel/record/tasks.rb
CHANGED
@@ -6,20 +6,46 @@ namespace :cequel do
|
|
6
6
|
namespace :keyspace do
|
7
7
|
desc 'Initialize Cassandra keyspace'
|
8
8
|
task :create => :environment do
|
9
|
-
|
10
|
-
puts "Created keyspace #{Cequel::Record.connection.name}"
|
9
|
+
create!
|
11
10
|
end
|
12
11
|
|
13
12
|
desc 'Drop Cassandra keyspace'
|
14
13
|
task :drop => :environment do
|
15
|
-
|
16
|
-
puts "Dropped keyspace #{Cequel::Record.connection.name}"
|
14
|
+
drop!
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
18
|
desc "Synchronize all models defined in `app/models' with Cassandra " \
|
21
19
|
"database schema"
|
22
20
|
task :migrate => :environment do
|
21
|
+
migrate
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Create keyspace and tables for all defined models"
|
25
|
+
task :init => %w(keyspace:create migrate)
|
26
|
+
|
27
|
+
|
28
|
+
desc 'Drop keyspace if exists, then create and migrate'
|
29
|
+
task :reset => :environment do
|
30
|
+
if Cequel::Record.connection.schema.exists?
|
31
|
+
drop!
|
32
|
+
end
|
33
|
+
create!
|
34
|
+
migrate
|
35
|
+
end
|
36
|
+
|
37
|
+
def create!
|
38
|
+
Cequel::Record.connection.schema.create!
|
39
|
+
puts "Created keyspace #{Cequel::Record.connection.name}"
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def drop!
|
44
|
+
Cequel::Record.connection.schema.drop!
|
45
|
+
puts "Dropped keyspace #{Cequel::Record.connection.name}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def migrate
|
23
49
|
watch_stack = ActiveSupport::Dependencies::WatchStack.new
|
24
50
|
|
25
51
|
migration_table_names = Set[]
|
@@ -58,7 +84,4 @@ namespace :cequel do
|
|
58
84
|
end
|
59
85
|
end
|
60
86
|
end
|
61
|
-
|
62
|
-
desc "Create keyspace and tables for all defined models"
|
63
|
-
task :init => %w(keyspace:create migrate)
|
64
87
|
end
|
@@ -73,31 +73,35 @@ module Cequel
|
|
73
73
|
# for now. It will be worth refactoring this code to take advantage of
|
74
74
|
# 2.0's better interface in a future version of Cequel that targets 2.0+.
|
75
75
|
def read_partition_keys
|
76
|
-
|
77
|
-
types = parse_composite_types(
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
validators = table_data['key_validator']
|
77
|
+
types = parse_composite_types(validators) || [validators]
|
78
|
+
columns = partition_columns.sort { |c| c['component_index'] }
|
79
|
+
.map { |c| c['column_name'] }
|
80
|
+
|
81
|
+
columns.zip(types) do |name, type|
|
82
|
+
table.add_partition_key(name.to_sym, Type.lookup_internal(type))
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
86
|
# XXX See comment on {read_partition_keys}
|
85
87
|
def read_clustering_columns
|
86
|
-
|
88
|
+
columns = cluster_columns.sort { |l, r| l['component_index'] <=> r['component_index'] }
|
89
|
+
.map { |c| c['column_name'] }
|
87
90
|
comparators = parse_composite_types(table_data['comparator'])
|
88
91
|
unless comparators
|
89
92
|
table.compact_storage = true
|
90
93
|
return unless column_data.empty?
|
91
|
-
|
94
|
+
columns << :column1 if cluster_columns.empty?
|
92
95
|
comparators = [table_data['comparator']]
|
93
96
|
end
|
94
|
-
|
97
|
+
|
98
|
+
columns.zip(comparators) do |name, type|
|
95
99
|
if REVERSED_TYPE_PATTERN =~ type
|
96
100
|
type = $1
|
97
101
|
clustering_order = :desc
|
98
102
|
end
|
99
103
|
table.add_clustering_column(
|
100
|
-
|
104
|
+
name.to_sym,
|
101
105
|
Type.lookup_internal(type),
|
102
106
|
clustering_order
|
103
107
|
)
|
@@ -107,7 +111,7 @@ module Cequel
|
|
107
111
|
def read_data_columns
|
108
112
|
if column_data.empty?
|
109
113
|
table.add_data_column(
|
110
|
-
(
|
114
|
+
(compact_value['column_name'] || :value).to_sym,
|
111
115
|
Type.lookup_internal(table_data['default_validator']),
|
112
116
|
false
|
113
117
|
)
|
@@ -163,18 +167,40 @@ module Cequel
|
|
163
167
|
@table_data = table_query.first.try(:to_hash)
|
164
168
|
end
|
165
169
|
|
166
|
-
def
|
167
|
-
@
|
170
|
+
def all_columns
|
171
|
+
@all_columns ||=
|
168
172
|
if table_data
|
169
173
|
column_query = keyspace.execute(<<-CQL, keyspace.name, table_name)
|
170
174
|
SELECT * FROM system.schema_columns
|
171
175
|
WHERE keyspace_name = ? AND columnfamily_name = ?
|
172
176
|
CQL
|
173
|
-
column_query.map(&:to_hash)
|
174
|
-
!column.key?('type') || column['type'] == 'regular'
|
175
|
-
end
|
177
|
+
column_query.map(&:to_hash)
|
176
178
|
end
|
177
179
|
end
|
180
|
+
|
181
|
+
def compact_value
|
182
|
+
@compact_value ||= all_columns.find do |column|
|
183
|
+
column['type'] == 'compact_value'
|
184
|
+
end || {}
|
185
|
+
end
|
186
|
+
|
187
|
+
def column_data
|
188
|
+
@column_data ||= all_columns.select do |column|
|
189
|
+
!column.key?('type') || column['type'] == 'regular'
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def partition_columns
|
194
|
+
@partition_columns ||= all_columns.select do |column|
|
195
|
+
column['type'] == 'partition_key'
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def cluster_columns
|
200
|
+
@cluster_columns ||= all_columns.select do |column|
|
201
|
+
column['type'] == 'clustering_key'
|
202
|
+
end
|
203
|
+
end
|
178
204
|
end
|
179
205
|
end
|
180
206
|
end
|
data/lib/cequel/version.rb
CHANGED
@@ -506,7 +506,7 @@ describe Cequel::Metal::DataSet do
|
|
506
506
|
expect(cequel[:posts].where(
|
507
507
|
:blog_subdomain => %w(cassandra big-data-weekly),
|
508
508
|
:permalink => 'big-data'
|
509
|
-
).map { |row| row[:title] }).to
|
509
|
+
).map { |row| row[:title] }).to match_array(['Big Data', 'Cassandra'])
|
510
510
|
end
|
511
511
|
|
512
512
|
it 'should use = if provided one-element array' do
|
@@ -86,6 +86,24 @@ describe Cequel::Metal::Keyspace do
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
describe "#ssl_config" do
|
90
|
+
it "ssl configuration settings get extracted correctly for sending to cluster" do
|
91
|
+
connect = Cequel.connect host: Cequel::SpecSupport::Helpers.host,
|
92
|
+
port: Cequel::SpecSupport::Helpers.port,
|
93
|
+
ssl: true,
|
94
|
+
server_cert: 'path/to/server_cert',
|
95
|
+
client_cert: 'path/to/client_cert',
|
96
|
+
private_key: 'private_key',
|
97
|
+
passphrase: 'passphrase'
|
98
|
+
|
99
|
+
expect(connect.ssl_config[:ssl]).to be true
|
100
|
+
expect(connect.ssl_config[:server_cert]).to eq('path/to/server_cert')
|
101
|
+
expect(connect.ssl_config[:client_cert]).to eq('path/to/client_cert')
|
102
|
+
expect(connect.ssl_config[:private_key]).to eq('private_key')
|
103
|
+
expect(connect.ssl_config[:passphrase]).to eq('passphrase')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
89
107
|
describe "#execute" do
|
90
108
|
let(:statement) { "SELECT id FROM posts" }
|
91
109
|
|
@@ -628,6 +628,48 @@ describe Cequel::Record::RecordSet do
|
|
628
628
|
end
|
629
629
|
end
|
630
630
|
|
631
|
+
describe '#first_or_initialize' do
|
632
|
+
context 'when there are posts' do
|
633
|
+
let(:post) { posts.first }
|
634
|
+
|
635
|
+
before { post }
|
636
|
+
|
637
|
+
it 'returns the first post' do
|
638
|
+
expect_any_instance_of(described_class).to receive(:first).and_return(post)
|
639
|
+
expect(Post.first_or_initialize).to eq post
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
context 'when there are no posts' do
|
644
|
+
it 'returns a new post instance' do
|
645
|
+
expect_any_instance_of(described_class).to receive(:first).and_return(nil)
|
646
|
+
expect_any_instance_of(described_class).to receive(:new).and_call_original
|
647
|
+
expect(Post.first_or_initialize).to be_new_record
|
648
|
+
end
|
649
|
+
end
|
650
|
+
end
|
651
|
+
|
652
|
+
describe '#first!' do
|
653
|
+
context 'when there are posts' do
|
654
|
+
let(:post) { posts.first }
|
655
|
+
|
656
|
+
before { post }
|
657
|
+
|
658
|
+
it 'returns the first post' do
|
659
|
+
expect_any_instance_of(described_class).to receive(:first).and_return(post)
|
660
|
+
expect(Post.first!).to eq post
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
context 'when there are no posts' do
|
665
|
+
it 'raises a RecordNotFound exception with a meaningful message' do
|
666
|
+
expect_any_instance_of(described_class).to receive(:first).and_return(nil)
|
667
|
+
expect { Post['1'].first! }.to raise_error Cequel::Record::RecordNotFound,
|
668
|
+
"Couldn't find record with keys: blog_subdomain: 1"
|
669
|
+
end
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
631
673
|
describe '#limit' do
|
632
674
|
let(:records) { blogs }
|
633
675
|
|
@@ -661,11 +703,6 @@ describe Cequel::Record::RecordSet do
|
|
661
703
|
context 'simple primary key' do
|
662
704
|
let(:records) { blogs }
|
663
705
|
|
664
|
-
it 'should correctly query for simple primary key with two arguments' do
|
665
|
-
expect(Blog.where(:subdomain, 'blog-0'))
|
666
|
-
.to eq(blogs.first(1))
|
667
|
-
end
|
668
|
-
|
669
706
|
it 'should correctly query for simple primary key with hash argument' do
|
670
707
|
expect(Blog.where(subdomain: 'blog-0'))
|
671
708
|
.to eq(blogs.first(1))
|
@@ -708,7 +745,7 @@ describe Cequel::Record::RecordSet do
|
|
708
745
|
|
709
746
|
context 'secondary indexed column' do
|
710
747
|
it 'should query for secondary indexed columns with two arguments' do
|
711
|
-
expect(Post.where(:
|
748
|
+
expect(Post.where(author_id: uuids.first).map(&:permalink)).
|
712
749
|
to eq(%w(cequel0 cequel2 cequel4))
|
713
750
|
end
|
714
751
|
|
@@ -723,13 +760,13 @@ describe Cequel::Record::RecordSet do
|
|
723
760
|
end
|
724
761
|
|
725
762
|
it 'should not allow chaining of multiple columns' do
|
726
|
-
expect { Post.where(:
|
727
|
-
where(:
|
763
|
+
expect { Post.where(author_id: uuids.first).
|
764
|
+
where(author_name: 'Mat Brown') }.
|
728
765
|
to raise_error(Cequel::Record::IllegalQuery)
|
729
766
|
end
|
730
767
|
|
731
768
|
it 'should cast argument for column' do
|
732
|
-
expect(Post.where(:
|
769
|
+
expect(Post.where(author_id: uuids.first.to_s).map(&:permalink)).
|
733
770
|
to eq(%w(cequel0 cequel2 cequel4))
|
734
771
|
end
|
735
772
|
end
|
@@ -753,14 +790,14 @@ describe Cequel::Record::RecordSet do
|
|
753
790
|
|
754
791
|
context 'nonexistent column' do
|
755
792
|
it 'should raise ArgumentError if column is not recognized' do
|
756
|
-
expect { Post.where(:
|
793
|
+
expect { Post.where(bogus: 'Business') }.
|
757
794
|
to raise_error(ArgumentError)
|
758
795
|
end
|
759
796
|
end
|
760
797
|
|
761
798
|
context 'non-indexed column' do
|
762
799
|
it 'should raise ArgumentError if column is not indexed' do
|
763
|
-
expect { Post.where(:
|
800
|
+
expect { Post.where(title: 'Cequel 0') }.
|
764
801
|
to raise_error(ArgumentError)
|
765
802
|
end
|
766
803
|
end
|
@@ -73,10 +73,10 @@ describe Cequel::Schema::Keyspace do
|
|
73
73
|
})
|
74
74
|
end
|
75
75
|
|
76
|
-
it "raises an error if a class other than SimpleStrategy is given"
|
76
|
+
it "raises an error if a class other than SimpleStrategy is given" do
|
77
77
|
expect {
|
78
78
|
keyspace.create! class: "NetworkTopologyStrategy", replication_factor: 2
|
79
|
-
}.to raise_error
|
79
|
+
}.to raise_error(RuntimeError)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -18,7 +18,6 @@ describe Cequel::SpecSupport::Preparation do
|
|
18
18
|
expect(prep.sync_schema).to eq prep
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
21
|
context "existing keyspace" do
|
23
22
|
it "can be deleted" do
|
24
23
|
prep.drop_keyspace
|
@@ -46,8 +45,8 @@ describe Cequel::SpecSupport::Preparation do
|
|
46
45
|
end
|
47
46
|
|
48
47
|
context "keyspace doesn't exist" do
|
49
|
-
before do
|
50
|
-
|
48
|
+
before(:each) do
|
49
|
+
Cequel::Record.connection.schema.drop!
|
51
50
|
end
|
52
51
|
|
53
52
|
it "doesn't cause failure upon drop requests" do
|
@@ -60,13 +59,19 @@ describe Cequel::SpecSupport::Preparation do
|
|
60
59
|
end
|
61
60
|
|
62
61
|
it "causes #sync_schema to fail" do
|
63
|
-
expect{ prep.sync_schema }.to raise_error
|
62
|
+
expect{ prep.sync_schema }.to raise_error(Cassandra::Errors::InvalidError)
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
66
|
# background
|
68
67
|
|
69
|
-
after
|
68
|
+
after(:each) do
|
69
|
+
begin
|
70
|
+
Cequel::Record.connection.schema.create!
|
71
|
+
rescue
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
end
|
70
75
|
|
71
76
|
matcher :contain_table do |table_name|
|
72
77
|
match do |keyspace|
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Brown
|
@@ -29,42 +29,36 @@ authors:
|
|
29
29
|
autorequire:
|
30
30
|
bindir: bin
|
31
31
|
cert_chain: []
|
32
|
-
date: 2015-
|
32
|
+
date: 2015-09-03 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
|
-
- - "
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.1'
|
41
|
-
- - "<"
|
38
|
+
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
40
|
+
version: '4.0'
|
44
41
|
type: :runtime
|
45
42
|
prerelease: false
|
46
43
|
version_requirements: !ruby/object:Gem::Requirement
|
47
44
|
requirements:
|
48
|
-
- - "
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '3.1'
|
51
|
-
- - "<"
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '4.0'
|
54
48
|
- !ruby/object:Gem::Dependency
|
55
49
|
name: cassandra-driver
|
56
50
|
requirement: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
54
|
+
version: '2.0'
|
61
55
|
type: :runtime
|
62
56
|
prerelease: false
|
63
57
|
version_requirements: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
61
|
+
version: '2.0'
|
68
62
|
- !ruby/object:Gem::Dependency
|
69
63
|
name: appraisal
|
70
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -325,14 +319,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
325
319
|
requirements:
|
326
320
|
- - ">="
|
327
321
|
- !ruby/object:Gem::Version
|
328
|
-
version: '
|
322
|
+
version: '2.0'
|
329
323
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
330
324
|
requirements:
|
331
325
|
- - ">="
|
332
326
|
- !ruby/object:Gem::Version
|
333
327
|
version: '0'
|
334
328
|
requirements:
|
335
|
-
- Cassandra >=
|
329
|
+
- Cassandra >= 2.0.0
|
336
330
|
rubyforge_project:
|
337
331
|
rubygems_version: 2.4.5
|
338
332
|
signing_key:
|