cequel 1.10.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +93 -65
  5. data/README.md +26 -5
  6. data/Vagrantfile +2 -2
  7. data/lib/cequel/errors.rb +2 -0
  8. data/lib/cequel/instrumentation.rb +5 -4
  9. data/lib/cequel/metal/batch.rb +21 -18
  10. data/lib/cequel/metal/data_set.rb +17 -28
  11. data/lib/cequel/metal/inserter.rb +3 -2
  12. data/lib/cequel/metal/keyspace.rb +56 -33
  13. data/lib/cequel/metal/request_logger.rb +22 -8
  14. data/lib/cequel/metal/row_specification.rb +9 -8
  15. data/lib/cequel/metal/statement.rb +23 -7
  16. data/lib/cequel/metal/updater.rb +12 -10
  17. data/lib/cequel/metal/writer.rb +5 -13
  18. data/lib/cequel/record/association_collection.rb +6 -33
  19. data/lib/cequel/record/collection.rb +2 -1
  20. data/lib/cequel/record/errors.rb +6 -0
  21. data/lib/cequel/record/persistence.rb +2 -2
  22. data/lib/cequel/record/record_set.rb +3 -4
  23. data/lib/cequel/record/validations.rb +5 -5
  24. data/lib/cequel/schema/table.rb +3 -5
  25. data/lib/cequel/schema/table_reader.rb +73 -111
  26. data/lib/cequel/schema/table_updater.rb +9 -15
  27. data/lib/cequel/version.rb +1 -1
  28. data/spec/examples/metal/data_set_spec.rb +34 -46
  29. data/spec/examples/metal/keyspace_spec.rb +8 -6
  30. data/spec/examples/record/associations_spec.rb +8 -18
  31. data/spec/examples/record/persistence_spec.rb +6 -6
  32. data/spec/examples/record/record_set_spec.rb +39 -12
  33. data/spec/examples/record/timestamps_spec.rb +12 -5
  34. data/spec/examples/schema/keyspace_spec.rb +13 -37
  35. data/spec/examples/schema/table_reader_spec.rb +4 -1
  36. data/spec/examples/schema/table_updater_spec.rb +22 -7
  37. data/spec/examples/schema/table_writer_spec.rb +2 -3
  38. data/spec/examples/spec_helper.rb +1 -0
  39. data/spec/examples/spec_support/preparation_spec.rb +14 -7
  40. metadata +7 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7ff155091be0d5464305a705c0ec81c48f43b63
4
- data.tar.gz: 6ddea2f0ae77a64b050cb77d44ead1970b3b1fec
3
+ metadata.gz: 72c4d009a896299d69e6d3f7aad381238fcb0483
4
+ data.tar.gz: e90819d05105818943bff45f774499bb63b66ec1
5
5
  SHA512:
6
- metadata.gz: dc693f1b953c426aaac6b65d51f5ae7038933d8040efe7272733f809784522a60b5575ff3fb9744f2f69c1a51f9c5348eb7195e9a4149faa1ad6f0a8c827e4ce
7
- data.tar.gz: b91aee5ec4d83c483a733cac281d1b1c91ac326f63f3b44a95458707edade557420ffcdcd1cd7018421d02504ea8861e585c0e516ad589c426469014664f1912
6
+ metadata.gz: d5b553d23b9df917acb80018becd971f4a05206a6c03e023f596593ce996706814550fbc40e3d9665a9a32804c82072eed4c64c39b18f2933e5400c25e31204a
7
+ data.tar.gz: 75e37e197a278752e4f2c7c18bfd712827601131ed61652519c762ae17d9cce954c546fc1e6db849598fecfb14d4b1e329fc037b9afa24c4e7fc6fb8feaf62f0
@@ -1,3 +1,14 @@
1
+ ## 2.0.0
2
+
3
+ * add support for Cassandra 3.x ([PR 324](https://github.com/cequel/cequel/pull/324))
4
+ * upgrade cassandra driver to 3.x ([PR 323](https://github.com/cequel/cequel/pull/323))
5
+ * add support for storing blobs (via parameterized CQL statements) ([PR 320](https://github.com/cequel/cequel/pull/320))
6
+ * add support for Rails 5 ([PR 310](https://github.com/cequel/cequel/pull/310))
7
+ * drop support for JRuby ([PR 310](https://github.com/cequel/cequel/pull/310))
8
+ * handle missing indexes gracefully ([PR 317](https://github.com/cequel/cequel/pull/317))
9
+ * Dropped support for count, length, and size as it results in unbounded run times and memory usage
10
+ ([PR 313](https://github.com/cequel/cequel/pull/313))
11
+
1
12
  ## 1.10.0
2
13
 
3
14
  * `:foreign_key` option for belongs_to associations
data/Gemfile CHANGED
@@ -15,3 +15,4 @@ end
15
15
  gem 'racc', '~> 1.4', :platforms => :rbx
16
16
  gem 'rubysl', '~> 2.0', :platforms => :rbx
17
17
  gem 'psych', '~> 2.0', :platforms => :rbx
18
+ gem 'activemodel-serializers-xml'
@@ -1,51 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (1.10.0)
5
- activemodel (~> 4.0)
6
- cassandra-driver (~> 2.0)
4
+ cequel (2.0.0)
5
+ activemodel (>= 4.0)
6
+ cassandra-driver (~> 3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (4.2.5.1)
12
- activesupport (= 4.2.5.1)
11
+ activemodel (5.0.0.1)
12
+ activesupport (= 5.0.0.1)
13
+ activemodel-serializers-xml (1.0.1)
14
+ activemodel (> 5.x)
15
+ activerecord (> 5.x)
16
+ activesupport (> 5.x)
13
17
  builder (~> 3.1)
14
- activesupport (4.2.5.1)
18
+ activerecord (5.0.0.1)
19
+ activemodel (= 5.0.0.1)
20
+ activesupport (= 5.0.0.1)
21
+ arel (~> 7.0)
22
+ activesupport (5.0.0.1)
23
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
24
  i18n (~> 0.7)
16
- json (~> 1.7, >= 1.7.7)
17
25
  minitest (~> 5.1)
18
- thread_safe (~> 0.3, >= 0.3.4)
19
26
  tzinfo (~> 1.1)
20
27
  addressable (2.4.0)
21
28
  appraisal (1.0.3)
22
29
  bundler
23
30
  rake
24
31
  thor (>= 0.14.0)
25
- ast (2.2.0)
32
+ arel (7.1.2)
33
+ ast (2.3.0)
26
34
  backports (3.6.8)
27
35
  builder (3.2.2)
28
36
  byebug (2.7.0)
29
37
  columnize (~> 0.3)
30
38
  debugger-linecache (~> 1.2)
31
- cassandra-driver (2.1.5)
39
+ cassandra-driver (3.0.3)
32
40
  ione (~> 1.2)
33
- coderay (1.1.0)
34
- columnize (0.8.9)
41
+ cassandra-driver (3.0.3-java)
42
+ ione (~> 1.2)
43
+ coderay (1.1.1)
44
+ columnize (0.9.0)
45
+ concurrent-ruby (1.0.2)
46
+ concurrent-ruby (1.0.2-java)
35
47
  debugger (1.6.8)
36
48
  columnize (>= 0.3.1)
37
49
  debugger-linecache (~> 1.2.0)
38
50
  debugger-ruby_core_source (~> 1.3.5)
39
51
  debugger-linecache (1.2.0)
40
- debugger-ruby_core_source (1.3.5)
52
+ debugger-ruby_core_source (1.3.8)
41
53
  diff-lcs (1.2.5)
42
- ethon (0.8.1)
54
+ ethon (0.9.1)
43
55
  ffi (>= 1.3.0)
44
56
  faraday (0.9.2)
45
57
  multipart-post (>= 1.2, < 3)
46
58
  faraday_middleware (0.10.0)
47
59
  faraday (>= 0.7.4, < 0.10)
48
- ffi (1.9.10)
60
+ ffi (1.9.14)
61
+ ffi (1.9.14-java)
49
62
  ffi2-generators (0.1.1)
50
63
  gh (0.14.0)
51
64
  addressable
@@ -57,54 +70,62 @@ GEM
57
70
  highline (1.7.8)
58
71
  i18n (0.7.0)
59
72
  ione (1.2.3)
60
- json (1.8.3)
73
+ json (2.0.2)
74
+ json (2.0.2-java)
61
75
  launchy (2.4.3)
62
76
  addressable (~> 2.3)
77
+ launchy (2.4.3-java)
78
+ addressable (~> 2.3)
79
+ spoon (~> 0.0.1)
63
80
  method_source (0.8.2)
64
- minitest (5.8.4)
65
- multi_json (1.11.2)
81
+ minitest (5.9.1)
82
+ multi_json (1.12.1)
66
83
  multipart-post (2.0.0)
67
84
  net-http-persistent (2.9.4)
68
85
  net-http-pipeline (1.0.1)
69
- parser (2.3.0.7)
86
+ parser (2.3.1.4)
70
87
  ast (~> 2.2)
71
88
  powerpack (0.1.1)
72
- pry (0.10.1)
89
+ pry (0.10.4)
90
+ coderay (~> 1.1.0)
91
+ method_source (~> 0.8.1)
92
+ slop (~> 3.4)
93
+ pry (0.10.4-java)
73
94
  coderay (~> 1.1.0)
74
95
  method_source (~> 0.8.1)
75
96
  slop (~> 3.4)
76
- psych (2.0.6)
97
+ spoon (~> 0.0)
98
+ psych (2.1.1)
77
99
  pusher-client (0.6.2)
78
100
  json
79
101
  websocket (~> 1.0)
80
- racc (1.4.12)
102
+ racc (1.4.14)
81
103
  rainbow (2.1.0)
82
- rake (10.3.2)
83
- rb-readline (0.5.1)
84
- rspec (3.4.0)
85
- rspec-core (~> 3.4.0)
86
- rspec-expectations (~> 3.4.0)
87
- rspec-mocks (~> 3.4.0)
88
- rspec-core (3.4.3)
89
- rspec-support (~> 3.4.0)
90
- rspec-expectations (3.4.0)
104
+ rake (10.5.0)
105
+ rspec (3.5.0)
106
+ rspec-core (~> 3.5.0)
107
+ rspec-expectations (~> 3.5.0)
108
+ rspec-mocks (~> 3.5.0)
109
+ rspec-core (3.5.4)
110
+ rspec-support (~> 3.5.0)
111
+ rspec-expectations (3.5.0)
91
112
  diff-lcs (>= 1.2.0, < 2.0)
92
- rspec-support (~> 3.4.0)
113
+ rspec-support (~> 3.5.0)
93
114
  rspec-its (1.2.0)
94
115
  rspec-core (>= 3.0.0)
95
116
  rspec-expectations (>= 3.0.0)
96
- rspec-mocks (3.4.1)
117
+ rspec-mocks (3.5.0)
97
118
  diff-lcs (>= 1.2.0, < 2.0)
98
- rspec-support (~> 3.4.0)
99
- rspec-support (3.4.1)
100
- rubocop (0.39.0)
101
- parser (>= 2.3.0.7, < 3.0)
119
+ rspec-support (~> 3.5.0)
120
+ rspec-support (3.5.0)
121
+ rubocop (0.43.0)
122
+ parser (>= 2.3.1.1, < 3.0)
102
123
  powerpack (~> 0.1)
103
124
  rainbow (>= 1.99.1, < 3.0)
104
125
  ruby-progressbar (~> 1.7)
105
126
  unicode-display_width (~> 1.0, >= 1.0.1)
106
- ruby-progressbar (1.7.5)
107
- rubysl (2.1.0)
127
+ ruby-progressbar (1.8.1)
128
+ rubysl (2.2.0)
108
129
  rubysl-abbrev (~> 2.0)
109
130
  rubysl-base64 (~> 2.0)
110
131
  rubysl-benchmark (~> 2.0)
@@ -189,6 +210,7 @@ GEM
189
210
  rubysl-tmpdir (~> 2.0)
190
211
  rubysl-tsort (~> 2.0)
191
212
  rubysl-un (~> 2.0)
213
+ rubysl-unicode_normalize (~> 2.0)
192
214
  rubysl-uri (~> 2.0)
193
215
  rubysl-weakref (~> 2.0)
194
216
  rubysl-webrick (~> 2.0)
@@ -200,22 +222,22 @@ GEM
200
222
  rubysl-benchmark (2.0.1)
201
223
  rubysl-bigdecimal (2.0.2)
202
224
  rubysl-cgi (2.0.1)
203
- rubysl-cgi-session (2.0.1)
225
+ rubysl-cgi-session (2.1.0)
204
226
  rubysl-cmath (2.0.0)
205
227
  rubysl-complex (2.0.0)
206
228
  rubysl-continuation (2.0.0)
207
- rubysl-coverage (2.0.3)
229
+ rubysl-coverage (2.1)
208
230
  rubysl-csv (2.0.2)
209
231
  rubysl-english (~> 2.0)
210
232
  rubysl-curses (2.0.1)
211
- rubysl-date (2.0.8)
233
+ rubysl-date (2.0.9)
212
234
  rubysl-delegate (2.0.1)
213
- rubysl-digest (2.0.3)
235
+ rubysl-digest (2.0.8)
214
236
  rubysl-drb (2.0.1)
215
237
  rubysl-e2mmap (2.0.0)
216
238
  rubysl-english (2.0.0)
217
239
  rubysl-enumerator (2.0.0)
218
- rubysl-erb (2.0.1)
240
+ rubysl-erb (2.0.2)
219
241
  rubysl-etc (2.0.3)
220
242
  ffi2-generators (~> 0.1)
221
243
  rubysl-expect (2.0.0)
@@ -233,16 +255,15 @@ GEM
233
255
  rubysl-io-nonblock (2.0.0)
234
256
  rubysl-io-wait (2.0.0)
235
257
  rubysl-ipaddr (2.0.0)
236
- rubysl-irb (2.1.0)
237
- rb-readline (~> 0.5)
258
+ rubysl-irb (2.1.1)
238
259
  rubysl-e2mmap (~> 2.0)
239
260
  rubysl-mathn (~> 2.0)
240
261
  rubysl-thread (~> 2.0)
241
- rubysl-logger (2.0.0)
262
+ rubysl-logger (2.1.0)
242
263
  rubysl-mathn (2.0.0)
243
264
  rubysl-matrix (2.1.0)
244
265
  rubysl-e2mmap (~> 2.0)
245
- rubysl-mkmf (2.0.1)
266
+ rubysl-mkmf (2.1)
246
267
  rubysl-fileutils (~> 2.0)
247
268
  rubysl-shellwords (~> 2.0)
248
269
  rubysl-monitor (2.0.0)
@@ -261,20 +282,20 @@ GEM
261
282
  rubysl-observer (2.0.0)
262
283
  rubysl-open-uri (2.0.0)
263
284
  rubysl-open3 (2.0.0)
264
- rubysl-openssl (2.2.0)
285
+ rubysl-openssl (2.8.0)
265
286
  rubysl-optparse (2.0.1)
266
287
  rubysl-shellwords (~> 2.0)
267
- rubysl-ostruct (2.0.4)
268
- rubysl-pathname (2.1.0)
288
+ rubysl-ostruct (2.1.0)
289
+ rubysl-pathname (2.3)
269
290
  rubysl-prettyprint (2.0.3)
270
291
  rubysl-prime (2.0.1)
271
292
  rubysl-profile (2.0.0)
272
- rubysl-profiler (2.0.1)
293
+ rubysl-profiler (2.1)
273
294
  rubysl-pstore (2.0.0)
274
- rubysl-pty (2.0.2)
295
+ rubysl-pty (2.0.3)
275
296
  rubysl-rational (2.0.1)
276
- rubysl-resolv (2.1.0)
277
- rubysl-rexml (2.0.2)
297
+ rubysl-resolv (2.1.2)
298
+ rubysl-rexml (2.0.4)
278
299
  rubysl-rinda (2.0.1)
279
300
  rubysl-rss (2.0.0)
280
301
  rubysl-scanf (2.0.0)
@@ -282,14 +303,15 @@ GEM
282
303
  rubysl-set (2.0.1)
283
304
  rubysl-shellwords (2.0.0)
284
305
  rubysl-singleton (2.0.0)
285
- rubysl-socket (2.0.1)
286
- rubysl-stringio (2.0.0)
306
+ rubysl-socket (2.1.2)
307
+ rubysl-fcntl (~> 2.0)
308
+ rubysl-stringio (2.1.0)
287
309
  rubysl-strscan (2.0.0)
288
310
  rubysl-sync (2.0.0)
289
- rubysl-syslog (2.0.1)
311
+ rubysl-syslog (2.1.0)
290
312
  ffi2-generators (~> 0.1)
291
313
  rubysl-tempfile (2.0.1)
292
- rubysl-thread (2.0.2)
314
+ rubysl-thread (2.0.3)
293
315
  rubysl-thwait (2.0.0)
294
316
  rubysl-time (2.0.3)
295
317
  rubysl-timeout (2.0.0)
@@ -298,16 +320,20 @@ GEM
298
320
  rubysl-un (2.0.0)
299
321
  rubysl-fileutils (~> 2.0)
300
322
  rubysl-optparse (~> 2.0)
323
+ rubysl-unicode_normalize (2.0)
301
324
  rubysl-uri (2.0.0)
302
325
  rubysl-weakref (2.0.0)
303
326
  rubysl-webrick (2.0.0)
304
327
  rubysl-xmlrpc (2.0.0)
305
- rubysl-yaml (2.0.4)
328
+ rubysl-yaml (2.1.0)
306
329
  rubysl-zlib (2.0.1)
307
330
  slop (3.6.0)
331
+ spoon (0.0.6)
332
+ ffi
308
333
  thor (0.19.1)
309
334
  thread_safe (0.3.5)
310
- timecop (0.7.1)
335
+ thread_safe (0.3.5-java)
336
+ timecop (0.8.1)
311
337
  travis (1.8.2)
312
338
  backports
313
339
  faraday (~> 0.9)
@@ -321,15 +347,17 @@ GEM
321
347
  ethon (>= 0.8.0)
322
348
  tzinfo (1.2.2)
323
349
  thread_safe (~> 0.1)
324
- unicode-display_width (1.0.3)
325
- websocket (1.2.2)
350
+ unicode-display_width (1.1.1)
351
+ websocket (1.2.3)
326
352
  wwtd (0.9.1)
327
- yard (0.8.7.6)
353
+ yard (0.9.5)
328
354
 
329
355
  PLATFORMS
356
+ java
330
357
  ruby
331
358
 
332
359
  DEPENDENCIES
360
+ activemodel-serializers-xml
333
361
  appraisal (~> 1.0)
334
362
  byebug (~> 2.7)
335
363
  cequel!
@@ -348,4 +376,4 @@ DEPENDENCIES
348
376
  yard (~> 0.6)
349
377
 
350
378
  BUNDLED WITH
351
- 1.11.2
379
+ 1.12.5
data/README.md CHANGED
@@ -24,6 +24,11 @@ Add it to your Gemfile:
24
24
  gem 'cequel'
25
25
  ```
26
26
 
27
+ If you use Rails 5, add this:
28
+ ``` ruby
29
+ gem 'activemodel-serializers-xml'
30
+ ```
31
+
27
32
  ### Rails integration ###
28
33
 
29
34
  Cequel does not require Rails, but if you are using Rails, you
@@ -88,8 +93,8 @@ specify the attribute used as the partition key.
88
93
 
89
94
  Note that the `belongs_to` declaration must come *before* the `key` declaration.
90
95
  This is because `belongs_to` defines the
91
- [partition key](http://www.datastax.com/documentation/cql/3.0/webhelp/index.html#cql/ddl/../../cassandra/glossary/gloss_glossary.html#glossentry_dhv_s24_bk); the `id` column is
92
- the [clustering column](http://www.datastax.com/documentation/cql/3.0/webhelp/index.html#glossentry_h31_xjk_bk).
96
+ [partition key](http://docs.datastax.com/en/glossary/doc/glossary/gloss_partition_key.html); the `id` column is
97
+ the [clustering column](http://docs.datastax.com/en/glossary/doc/glossary/gloss_clustering_column.html).
93
98
 
94
99
  Practically speaking, this means that posts are accessed using both the
95
100
  `blog_subdomain` (automatically defined by the `belongs_to` association) and the
@@ -224,7 +229,7 @@ multiple queries in your logs if you're iterating over a huge result set.
224
229
  #### Time UUID Queries ####
225
230
 
226
231
  CQL has [special handling for the `timeuuid`
227
- type](http://www.datastax.com/documentation/cql/3.0/webhelp/index.html#cql/cql_reference/cql_data_types_c.html#reference_ds_axc_xk5_yj),
232
+ type](https://docs.datastax.com/en/cql/3.3/cql/cql_reference/uuid_type_r.html),
228
233
  which allows you to return a rows whose UUID keys correspond to a range of
229
234
  timestamps.
230
235
 
@@ -534,6 +539,14 @@ essentially the same thing: both simply persist the given column data at the
534
539
  given key(s). So, you may think you are creating a new record, but in fact
535
540
  you're overwriting data at an existing record:
536
541
 
542
+ #### Counting ####
543
+
544
+ Counting is not the same as in a RDB, as it can have a much longer runtime and
545
+ can put unexpected load on your cluster. As a result Cequel does not support
546
+ this feature. It is still possible to execute raw cql to get the counts, should
547
+ you require this functionality.
548
+ `MyModel.connection.execute('select count(*) from table_name;').first['count']`
549
+
537
550
  ``` ruby
538
551
  # I'm just creating a blog here.
539
552
  blog1 = Blog.create!(
@@ -557,6 +570,7 @@ the columns that are given.
557
570
 
558
571
  ### Rails ###
559
572
 
573
+ * 5.0
560
574
  * 4.2
561
575
  * 4.1
562
576
  * 4.0
@@ -564,13 +578,18 @@ the columns that are given.
564
578
  ### Ruby ###
565
579
 
566
580
  * Ruby 2.3, 2.2, 2.1, 2.0
567
- * JRuby 1.7, 9.0
568
581
 
569
582
  ### Cassandra ###
570
583
 
571
584
  * 2.1.x
572
585
  * 2.2.x
586
+ * 3.0.x
587
+
588
+ ## Breaking API changes
589
+
590
+ ### 2.0
573
591
 
592
+ * dropped support for jruby (Due to difficult to work around bugs in jruby. PRs welcome to restore jruby compatibility.)
574
593
 
575
594
  ## Support & Bugs ##
576
595
 
@@ -616,8 +635,10 @@ Cequel was written by:
616
635
  * Luke Duncalfe
617
636
  * Eric Betts
618
637
  * Maxim Dobryakov
638
+ * Yi-Cyuan Chen
639
+ * Justin Hannus
619
640
 
620
- Special thanks to [Brewster](https://www.brewster.com), which supported the 0.x
641
+ Special thanks to [Brewster](http://www.brewster.com), which supported the 0.x
621
642
  releases of Cequel.
622
643
 
623
644
  ## Shameless Self-Promotion ##
@@ -135,9 +135,9 @@ 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(/^2\.[12]\./)
138
+ .map(&:strip).grep(/(^2\.[12]\.)|(^3.)/)
139
139
  versions.each do |version|
140
- java_version = version =~ /^1/ ? '6' : '7'
140
+ java_version = version =~ /^2/ ? '7' : '8'
141
141
  config.vm.define version do |machine|
142
142
  machine.vm.provision :shell, inline: provision,
143
143
  args: [version, java_version]
@@ -8,4 +8,6 @@ module Cequel
8
8
  # key)
9
9
  #
10
10
  InvalidSchemaMigration = Class.new(StandardError)
11
+
12
+ NoSuchKeyspaceError = Class.new(StandardError)
11
13
  end