cequel 3.0.2 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +19 -7
- data/Dockerfile +29 -0
- data/Gemfile.lock +10 -10
- data/README.md +3 -2
- data/lib/cequel/metal/batch_manager.rb +4 -3
- data/lib/cequel/metal/data_set.rb +2 -4
- data/lib/cequel/record/associations.rb +0 -2
- data/lib/cequel/record/collection.rb +2 -2
- data/lib/cequel/record/dirty.rb +6 -2
- data/lib/cequel/record/persistence.rb +15 -15
- data/lib/cequel/record/properties.rb +7 -7
- data/lib/cequel/record/record_set.rb +39 -32
- data/lib/cequel/record/scoped.rb +1 -1
- data/lib/cequel/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b2ad23f8a516eb2960f68a69b5d33d87ba81b99
|
4
|
+
data.tar.gz: 794306c91044e4e766694c0f029a3eba596e5552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68ae5930111f56d55bdedcef4e1999d21483e6c2a223961f5a249b05f9f4b25ee966e88cc7f4092276e0fb5e6b76769b285abd979cb340c0c35c4b8dab51aa78
|
7
|
+
data.tar.gz: a5ca1b83b34b2b6a00ebfa9bed2e075ebe4e569f0254563e6d5c432c25f1c51d01bb1e2ea536c58ac89635b727909d5c8d28ad4777f32cc9e43f70c8d820d131
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -41,23 +41,35 @@ bundle exec rake test
|
|
41
41
|
|
42
42
|
### Using Docker
|
43
43
|
|
44
|
-
Cequel's test suite
|
45
|
-
|
44
|
+
Cequel's test suite, including a development bash environment, container, and Cassandra
|
45
|
+
instance is setup for use through Docker Compose.
|
46
46
|
|
47
|
-
|
47
|
+
The local folder is mapped into the docker container. So, you can use your IDE of choice
|
48
|
+
to make edits, leveraging the docker-compose to provide Cassandra and an lightweight container for
|
49
|
+
running tests.
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
To use, update the docker-compose.yml with your personal details (for Git compatibility) and then:
|
52
|
+
```bash
|
53
|
+
docker-compose run dev
|
54
|
+
```
|
55
|
+
This will drop you to a bash prompt in the `/cequel/` folder. From there, you can run
|
56
|
+
tests using familiar RSpec commands.
|
52
57
|
|
53
58
|
### Cassandra versions
|
54
59
|
|
55
60
|
Cequel is tested against a large range of Ruby, Rails, and Cassandra
|
56
|
-
versions; for most patches, you can
|
61
|
+
versions; for most patches, you can develop the tests using the
|
57
62
|
latest version of all of them. If you're messing with the
|
58
63
|
`Cequel::Schema` or `Cequel::Type` modules, you'll want to test at
|
59
64
|
least against the first and latest releases of 2.1, 2.2 and 3 series.
|
60
65
|
|
66
|
+
If want to use a specific version of Cassandra in development do this:
|
67
|
+
|
68
|
+
```bash
|
69
|
+
docker-compose down
|
70
|
+
CASSANDRA_VERSION=3.10 docker-compose run dev
|
71
|
+
```
|
72
|
+
|
61
73
|
## And finally
|
62
74
|
|
63
75
|
**THANK YOU!**
|
data/Dockerfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
FROM ruby:alpine
|
2
|
+
|
3
|
+
# Put the basic system setup in a layer of its own so we don't have
|
4
|
+
# rebuild it all the time.
|
5
|
+
RUN apk add --update build-base tzdata bash bash-completion git \
|
6
|
+
&& rm -rf /var/cache/apk/*
|
7
|
+
|
8
|
+
WORKDIR /cequel
|
9
|
+
|
10
|
+
# Make it nicer to run tests.. now "ber" instead of "bundle exec rspec" and "bi" instead of "bundle install"
|
11
|
+
RUN echo 'alias be="bundle exec"' >> ~/.bashrc \
|
12
|
+
&& echo 'alias ber="bundle exec rspec"' >> ~/.bashrc \
|
13
|
+
&& echo 'alias bi="bundle install"' >> ~/.bashrc
|
14
|
+
|
15
|
+
# Put the bundle in a layer of its own. The bundle doesn't change
|
16
|
+
# that often to copy just the Gemfiles and bundle to build a layer
|
17
|
+
# that rarely changes
|
18
|
+
COPY ./Gemfile* /cequel/
|
19
|
+
COPY ./cequel.gemspec /cequel/
|
20
|
+
RUN mkdir -p /cequel/lib/cequel/
|
21
|
+
COPY ./lib/cequel/version.rb /cequel/lib/cequel/
|
22
|
+
RUN gem install bundler \
|
23
|
+
&& bundle install
|
24
|
+
|
25
|
+
|
26
|
+
COPY ./* /cequel/
|
27
|
+
|
28
|
+
|
29
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cequel (3.0.
|
4
|
+
cequel (3.0.4)
|
5
5
|
activemodel (>= 4.0)
|
6
6
|
cassandra-driver (~> 3.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (5.1
|
12
|
-
activesupport (= 5.1
|
13
|
-
activesupport (5.1
|
11
|
+
activemodel (5.2.1)
|
12
|
+
activesupport (= 5.2.1)
|
13
|
+
activesupport (5.2.1)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
-
i18n (
|
15
|
+
i18n (>= 0.7, < 2)
|
16
16
|
minitest (~> 5.1)
|
17
17
|
tzinfo (~> 1.1)
|
18
18
|
addressable (2.4.0)
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
byebug (2.7.0)
|
26
26
|
columnize (~> 0.3)
|
27
27
|
debugger-linecache (~> 1.2)
|
28
|
-
cassandra-driver (3.2.
|
28
|
+
cassandra-driver (3.2.3)
|
29
29
|
ione (~> 1.2)
|
30
30
|
coderay (1.1.2)
|
31
31
|
columnize (0.9.0)
|
@@ -49,7 +49,7 @@ GEM
|
|
49
49
|
net-http-persistent (~> 2.9)
|
50
50
|
net-http-pipeline
|
51
51
|
highline (1.7.8)
|
52
|
-
i18n (
|
52
|
+
i18n (1.1.1)
|
53
53
|
concurrent-ruby (~> 1.0)
|
54
54
|
ione (1.2.4)
|
55
55
|
json (2.1.0)
|
@@ -60,7 +60,7 @@ GEM
|
|
60
60
|
addressable (~> 2.3)
|
61
61
|
spoon (~> 0.0.1)
|
62
62
|
method_source (0.9.0)
|
63
|
-
minitest (5.
|
63
|
+
minitest (5.11.3)
|
64
64
|
multi_json (1.12.2)
|
65
65
|
multipart-post (2.0.0)
|
66
66
|
net-http-persistent (2.9.4)
|
@@ -327,7 +327,7 @@ GEM
|
|
327
327
|
typhoeus (~> 0.6, >= 0.6.8)
|
328
328
|
typhoeus (0.8.0)
|
329
329
|
ethon (>= 0.8.0)
|
330
|
-
tzinfo (1.2.
|
330
|
+
tzinfo (1.2.5)
|
331
331
|
thread_safe (~> 0.1)
|
332
332
|
unicode-display_width (1.3.0)
|
333
333
|
websocket (1.2.4)
|
@@ -357,4 +357,4 @@ DEPENDENCIES
|
|
357
357
|
yard (~> 0.6)
|
358
358
|
|
359
359
|
BUNDLED WITH
|
360
|
-
1.
|
360
|
+
1.17.1
|
data/README.md
CHANGED
@@ -594,7 +594,8 @@ you require this functionality.
|
|
594
594
|
## Compatibility ##
|
595
595
|
|
596
596
|
### Rails ###
|
597
|
-
|
597
|
+
* 5.2
|
598
|
+
* 5.1
|
598
599
|
* 5.0
|
599
600
|
* 4.2
|
600
601
|
* 4.1
|
@@ -602,7 +603,7 @@ you require this functionality.
|
|
602
603
|
|
603
604
|
### Ruby ###
|
604
605
|
|
605
|
-
* Ruby 2.3, 2.2, 2.1, 2.0
|
606
|
+
* Ruby 2.5, 2,4, 2.3, 2.2, 2.1, 2.0
|
606
607
|
|
607
608
|
### Cassandra ###
|
608
609
|
|
@@ -55,13 +55,14 @@ module Cequel
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
def current_batch
|
59
|
+
::Thread.current[batch_key]
|
60
|
+
end
|
61
|
+
|
58
62
|
private
|
59
63
|
|
60
64
|
attr_reader :keyspace
|
61
65
|
|
62
|
-
def current_batch
|
63
|
-
::Thread.current[batch_key]
|
64
|
-
end
|
65
66
|
|
66
67
|
def current_batch=(batch)
|
67
68
|
::Thread.current[batch_key] = batch
|
@@ -696,12 +696,8 @@ module Cequel
|
|
696
696
|
end
|
697
697
|
end
|
698
698
|
|
699
|
-
protected
|
700
|
-
|
701
699
|
attr_writer :row_limit, :query_consistency, :query_page_size, :query_paging_state, :allow_filtering
|
702
700
|
|
703
|
-
private
|
704
|
-
|
705
701
|
def results
|
706
702
|
@results ||= execute_cql(cql)
|
707
703
|
end
|
@@ -730,6 +726,8 @@ module Cequel
|
|
730
726
|
Deleter.new(self, &block)
|
731
727
|
end
|
732
728
|
|
729
|
+
private
|
730
|
+
|
733
731
|
def initialize_copy(source)
|
734
732
|
super
|
735
733
|
@select_columns = source.select_columns.clone
|
@@ -218,7 +218,7 @@ module Cequel
|
|
218
218
|
# @param elements [Array] new elements to replace in this range
|
219
219
|
#
|
220
220
|
def []=(*args)
|
221
|
-
if args[0].is_a?(
|
221
|
+
if args[0].is_a?(Integer) && args.count == 2
|
222
222
|
# single element set/replace
|
223
223
|
elem = cast_element(args[1])
|
224
224
|
|
@@ -231,7 +231,7 @@ module Cequel
|
|
231
231
|
# multi-element set/replace
|
232
232
|
range = if args[0].is_a?(Range)
|
233
233
|
args[0]
|
234
|
-
elsif args[0].is_a?(
|
234
|
+
elsif args[0].is_a?(Integer) && args[1].is_a?(Integer)
|
235
235
|
args[0]..(args[0]+args[1]-1)
|
236
236
|
else
|
237
237
|
Kernel.raise ArgumentError, "[i]=elem or [i,count]=elems or [a..b]=elems"
|
data/lib/cequel/record/dirty.rb
CHANGED
@@ -47,8 +47,12 @@ module Cequel
|
|
47
47
|
def save(options = {})
|
48
48
|
super.tap do |success|
|
49
49
|
if success
|
50
|
-
|
51
|
-
|
50
|
+
if self.respond_to?(:changes_applied)
|
51
|
+
changes_applied
|
52
|
+
else
|
53
|
+
@previously_changed = changes
|
54
|
+
@changed_attributes.clear
|
55
|
+
end
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
@@ -82,7 +82,7 @@ module Cequel
|
|
82
82
|
# @since 1.0.0
|
83
83
|
#
|
84
84
|
def key_attributes
|
85
|
-
@
|
85
|
+
@cequel_attributes.slice(*self.class.key_column_names)
|
86
86
|
end
|
87
87
|
|
88
88
|
#
|
@@ -160,7 +160,7 @@ module Cequel
|
|
160
160
|
# @since 1.0.0
|
161
161
|
#
|
162
162
|
def loaded?(column = nil)
|
163
|
-
!!@loaded && (column.nil? || @
|
163
|
+
!!@loaded && (column.nil? || @cequel_attributes.key?(column.to_sym))
|
164
164
|
end
|
165
165
|
|
166
166
|
#
|
@@ -260,6 +260,16 @@ module Cequel
|
|
260
260
|
self
|
261
261
|
end
|
262
262
|
|
263
|
+
def updater
|
264
|
+
raise ArgumentError, "Can't get updater for new record" if new_record?
|
265
|
+
@updater ||= Metal::Updater.new(metal_scope)
|
266
|
+
end
|
267
|
+
|
268
|
+
def deleter
|
269
|
+
raise ArgumentError, "Can't get deleter for new record" if new_record?
|
270
|
+
@deleter ||= Metal::Deleter.new(metal_scope)
|
271
|
+
end
|
272
|
+
|
263
273
|
protected
|
264
274
|
|
265
275
|
def persisted!
|
@@ -291,16 +301,6 @@ module Cequel
|
|
291
301
|
end
|
292
302
|
instrument :update, data: ->(rec) { {table_name: rec.table_name} }
|
293
303
|
|
294
|
-
def updater
|
295
|
-
raise ArgumentError, "Can't get updater for new record" if new_record?
|
296
|
-
@updater ||= Metal::Updater.new(metal_scope)
|
297
|
-
end
|
298
|
-
|
299
|
-
def deleter
|
300
|
-
raise ArgumentError, "Can't get deleter for new record" if new_record?
|
301
|
-
@deleter ||= Metal::Deleter.new(metal_scope)
|
302
|
-
end
|
303
|
-
|
304
304
|
private
|
305
305
|
|
306
306
|
def_delegators 'self.class', :connection, :table
|
@@ -361,17 +361,17 @@ module Cequel
|
|
361
361
|
end
|
362
362
|
|
363
363
|
def attributes_for_create
|
364
|
-
@
|
364
|
+
@cequel_attributes.each_with_object({}) do |(column, value), attributes|
|
365
365
|
attributes[column] = value unless value.nil?
|
366
366
|
end
|
367
367
|
end
|
368
368
|
|
369
369
|
def attributes_for_update
|
370
|
-
@
|
370
|
+
@cequel_attributes_for_update ||= {}
|
371
371
|
end
|
372
372
|
|
373
373
|
def attributes_for_deletion
|
374
|
-
@
|
374
|
+
@cequel_attributes_for_deletion ||= []
|
375
375
|
end
|
376
376
|
|
377
377
|
def assert_keys_present!
|
@@ -281,7 +281,7 @@ module Cequel
|
|
281
281
|
|
282
282
|
# @private
|
283
283
|
def initialize(attributes = {}, record_collection = nil)
|
284
|
-
@
|
284
|
+
@cequel_attributes, @record_collection = attributes, record_collection
|
285
285
|
@collection_proxies = {}
|
286
286
|
end
|
287
287
|
|
@@ -289,7 +289,7 @@ module Cequel
|
|
289
289
|
# @return [Array<Symbol>] list of names of attributes on this record
|
290
290
|
#
|
291
291
|
def attribute_names
|
292
|
-
@
|
292
|
+
@cequel_attributes.keys
|
293
293
|
end
|
294
294
|
|
295
295
|
#
|
@@ -367,7 +367,7 @@ module Cequel
|
|
367
367
|
protected
|
368
368
|
|
369
369
|
def read_attribute(name)
|
370
|
-
@
|
370
|
+
@cequel_attributes.fetch(name)
|
371
371
|
rescue KeyError
|
372
372
|
if self.class.reflect_on_column(name)
|
373
373
|
fail MissingAttributeError, "missing attribute: #{name}"
|
@@ -382,7 +382,7 @@ module Cequel
|
|
382
382
|
end
|
383
383
|
|
384
384
|
send("#{name}_will_change!") unless value === read_attribute(name)
|
385
|
-
@
|
385
|
+
@cequel_attributes[name] = value
|
386
386
|
end
|
387
387
|
|
388
388
|
private
|
@@ -397,14 +397,14 @@ module Cequel
|
|
397
397
|
end
|
398
398
|
|
399
399
|
def init_attributes(new_attributes)
|
400
|
-
@
|
400
|
+
@cequel_attributes = {}
|
401
401
|
new_attributes.each_pair do |name, value|
|
402
402
|
if value.nil?
|
403
403
|
value = empty_attributes.fetch(name.to_sym) { -> {} }.call
|
404
404
|
end
|
405
|
-
@
|
405
|
+
@cequel_attributes[name.to_sym] = value
|
406
406
|
end
|
407
|
-
@
|
407
|
+
@cequel_attributes
|
408
408
|
end
|
409
409
|
|
410
410
|
def initialize_new_record(attributes = {})
|
@@ -123,7 +123,7 @@ module Cequel
|
|
123
123
|
#
|
124
124
|
def initialize(target_class, attributes = {})
|
125
125
|
attributes = self.class.default_attributes.merge!(attributes)
|
126
|
-
@target_class, @
|
126
|
+
@target_class, @cequel_attributes = target_class, attributes
|
127
127
|
super(target_class)
|
128
128
|
end
|
129
129
|
|
@@ -705,19 +705,49 @@ module Cequel
|
|
705
705
|
entries
|
706
706
|
end
|
707
707
|
|
708
|
-
|
708
|
+
def attributes
|
709
|
+
cequel_attributes
|
710
|
+
end
|
711
|
+
|
712
|
+
def attributes=(attrs)
|
713
|
+
self.cequel_attributes = attr
|
714
|
+
end
|
715
|
+
|
716
|
+
attr_accessor :cequel_attributes
|
717
|
+
|
718
|
+
def unscoped_key_names
|
719
|
+
unscoped_key_columns.map { |column| column.name }
|
720
|
+
end
|
721
|
+
|
722
|
+
def order_by_column
|
723
|
+
if target_class.clustering_columns.any?
|
724
|
+
target_class.clustering_columns.first
|
725
|
+
end
|
726
|
+
end
|
709
727
|
|
710
|
-
|
711
|
-
|
728
|
+
def scoped_key_names
|
729
|
+
scoped_key_columns.map { |column| column.name }
|
730
|
+
end
|
731
|
+
|
732
|
+
hattr_inquirer :attributes, :reversed
|
733
|
+
|
734
|
+
def ascends_by?(column)
|
735
|
+
!descends_by?(column)
|
736
|
+
end
|
737
|
+
|
738
|
+
def descends_by?(column)
|
739
|
+
column.clustering_column? &&
|
740
|
+
(reversed? ^ (column.clustering_order == :desc))
|
741
|
+
end
|
742
|
+
|
743
|
+
|
744
|
+
hattr_reader :cequel_attributes, :select_columns, :scoped_key_values,
|
712
745
|
:row_limit, :lower_bound, :upper_bound,
|
713
746
|
:scoped_indexed_column, :query_consistency,
|
714
747
|
:query_page_size, :query_paging_state,
|
715
748
|
:allow_filtering
|
716
|
-
|
717
|
-
|
718
|
-
:query_page_size, :query_paging_state, :allow_filtering
|
719
|
-
hattr_inquirer :attributes, :reversed
|
720
|
-
protected :reversed?
|
749
|
+
|
750
|
+
protected
|
721
751
|
|
722
752
|
def next_batch_from(row)
|
723
753
|
range_key_value = row[range_key_name]
|
@@ -728,15 +758,6 @@ module Cequel
|
|
728
758
|
end
|
729
759
|
end
|
730
760
|
|
731
|
-
def ascends_by?(column)
|
732
|
-
!descends_by?(column)
|
733
|
-
end
|
734
|
-
|
735
|
-
def descends_by?(column)
|
736
|
-
column.clustering_column? &&
|
737
|
-
(reversed? ^ (column.clustering_order == :desc))
|
738
|
-
end
|
739
|
-
|
740
761
|
def find_nested_batches_from(row, options, &block)
|
741
762
|
return unless next_range_key_column
|
742
763
|
|
@@ -836,10 +857,6 @@ module Cequel
|
|
836
857
|
scoped(scoped_indexed_column: {column_name => column.cast(value)})
|
837
858
|
end
|
838
859
|
|
839
|
-
def scoped_key_names
|
840
|
-
scoped_key_columns.map { |column| column.name }
|
841
|
-
end
|
842
|
-
|
843
860
|
def scoped_key_columns
|
844
861
|
target_class.key_columns.first(scoped_key_values.length)
|
845
862
|
end
|
@@ -848,10 +865,6 @@ module Cequel
|
|
848
865
|
target_class.key_columns.drop(scoped_key_values.length)
|
849
866
|
end
|
850
867
|
|
851
|
-
def unscoped_key_names
|
852
|
-
unscoped_key_columns.map { |column| column.name }
|
853
|
-
end
|
854
|
-
|
855
868
|
def range_key_column
|
856
869
|
unscoped_key_columns.first
|
857
870
|
end
|
@@ -913,12 +926,6 @@ module Cequel
|
|
913
926
|
end
|
914
927
|
end
|
915
928
|
|
916
|
-
def order_by_column
|
917
|
-
if target_class.clustering_columns.any?
|
918
|
-
target_class.clustering_columns.first
|
919
|
-
end
|
920
|
-
end
|
921
|
-
|
922
929
|
def selects_collection_columns?
|
923
930
|
select_columns.any? do |column_name|
|
924
931
|
target_class.reflect_on_column(column_name).collection_column?
|
data/lib/cequel/record/scoped.rb
CHANGED
data/lib/cequel/version.rb
CHANGED
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: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Brown
|
@@ -26,10 +26,11 @@ authors:
|
|
26
26
|
- Tamara Temple
|
27
27
|
- Long On
|
28
28
|
- Lucas Mundim
|
29
|
+
- William Flanagan
|
29
30
|
autorequire:
|
30
31
|
bindir: bin
|
31
32
|
cert_chain: []
|
32
|
-
date: 2018-04
|
33
|
+
date: 2018-11-04 00:00:00.000000000 Z
|
33
34
|
dependencies:
|
34
35
|
- !ruby/object:Gem::Dependency
|
35
36
|
name: activemodel
|
@@ -207,12 +208,12 @@ description: |
|
|
207
208
|
email: mat.a.brown@gmail.com
|
208
209
|
executables: []
|
209
210
|
extensions: []
|
210
|
-
extra_rdoc_files:
|
211
|
-
- README.md
|
211
|
+
extra_rdoc_files: []
|
212
212
|
files:
|
213
213
|
- Appraisals
|
214
214
|
- CHANGELOG.md
|
215
215
|
- CONTRIBUTING.md
|
216
|
+
- Dockerfile
|
216
217
|
- Gemfile
|
217
218
|
- Gemfile.lock
|
218
219
|
- LICENSE
|
@@ -342,7 +343,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
342
343
|
requirements:
|
343
344
|
- Cassandra >= 2.0.0
|
344
345
|
rubyforge_project:
|
345
|
-
rubygems_version: 2.
|
346
|
+
rubygems_version: 2.6.13
|
346
347
|
signing_key:
|
347
348
|
specification_version: 4
|
348
349
|
summary: Full-featured, ActiveModel-compliant ORM for Cassandra using CQL3
|