datastax_rails 2.0.18 → 2.1.23
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/config/solrconfig.xml.erb +7 -7
- data/lib/datastax_rails/associations/collection_association.rb +4 -4
- data/lib/datastax_rails/associations/has_many_association.rb +1 -1
- data/lib/datastax_rails/attribute_methods/dirty.rb +6 -0
- data/lib/datastax_rails/attribute_methods/primary_key.rb +9 -1
- data/lib/datastax_rails/attribute_methods/read.rb +2 -2
- data/lib/datastax_rails/attribute_methods/typecasting.rb +4 -7
- data/lib/datastax_rails/attribute_methods.rb +25 -0
- data/lib/datastax_rails/autosave_association.rb +3 -3
- data/lib/datastax_rails/base.rb +33 -11
- data/lib/datastax_rails/column.rb +25 -15
- data/lib/datastax_rails/connection.rb +1 -1
- data/lib/datastax_rails/cql/base.rb +31 -19
- data/lib/datastax_rails/cql/select.rb +2 -2
- data/lib/datastax_rails/dynamic_model.rb +1 -1
- data/lib/datastax_rails/errors.rb +3 -0
- data/lib/datastax_rails/instrumentation/controller_runtime.rb +52 -0
- data/lib/datastax_rails/instrumentation/log_subscriber.rb +92 -0
- data/lib/datastax_rails/instrumentation.rb +4 -0
- data/lib/datastax_rails/persistence.rb +49 -17
- data/lib/datastax_rails/railtie.rb +7 -0
- data/lib/datastax_rails/reflection.rb +16 -12
- data/lib/datastax_rails/relation/batches.rb +1 -1
- data/lib/datastax_rails/relation/finder_methods.rb +5 -5
- data/lib/datastax_rails/relation/modification_methods.rb +11 -26
- data/lib/datastax_rails/relation/search_methods.rb +10 -11
- data/lib/datastax_rails/relation.rb +81 -50
- data/lib/datastax_rails/scoping.rb +1 -1
- data/lib/datastax_rails/serialization.rb +10 -6
- data/lib/datastax_rails/serializers/xml_serializer.rb +3 -1
- data/lib/datastax_rails/tasks/ds.rake +25 -26
- data/lib/datastax_rails/timestamps.rb +1 -1
- data/lib/datastax_rails/types/dynamic_set.rb +4 -0
- data/lib/datastax_rails/version.rb +1 -1
- data/lib/datastax_rails/wide_storage_model.rb +3 -1
- data/lib/datastax_rails.rb +1 -0
- data/spec/datastax_rails/attribute_methods/read_spec.rb +33 -0
- data/spec/datastax_rails/attribute_methods/typecasting_spec.rb +25 -0
- data/spec/datastax_rails/base_spec.rb +1 -1
- data/spec/datastax_rails/callbacks_spec.rb +6 -0
- data/spec/datastax_rails/column_spec.rb +20 -0
- data/spec/datastax_rails/cql/base_spec.rb +1 -1
- data/spec/datastax_rails/cql/select_spec.rb +7 -1
- data/spec/datastax_rails/persistence_spec.rb +22 -3
- data/spec/datastax_rails/relation/finder_methods_spec.rb +13 -0
- data/spec/datastax_rails/relation/search_methods_spec.rb +37 -12
- data/spec/datastax_rails/serialization_spec.rb +17 -0
- data/spec/dummy/log/development.log +0 -24195
- data/spec/dummy/log/test.log +20 -15610
- data/spec/factories/hobbies.rb +1 -0
- data/spec/factories/jobs.rb +7 -0
- data/spec/factories/people.rb +1 -0
- data/spec/factories/person_roles.rb +7 -0
- data/spec/factories/roles.rb +6 -0
- data/spec/factories/uuid_keys.rb +6 -0
- data/spec/feature/associations_spec.rb +26 -0
- data/spec/support/models.rb +82 -0
- metadata +19 -4
- data/spec/dummy/log/production.log +0 -2
@@ -53,7 +53,7 @@ describe DatastaxRails::Relation do
|
|
53
53
|
Hobby.create(name: word)
|
54
54
|
end
|
55
55
|
@relation.commit_solr
|
56
|
-
expect(@relation.order(:name).map
|
56
|
+
expect(@relation.order(:name).map(&:name)).to eq(%w(boating chess fishing hiking jogging swimming))
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should return items in descending order' do
|
@@ -61,7 +61,7 @@ describe DatastaxRails::Relation do
|
|
61
61
|
Hobby.create!(name: word)
|
62
62
|
end
|
63
63
|
@relation.commit_solr
|
64
|
-
expect(@relation.order(name: :desc).map
|
64
|
+
expect(@relation.order(name: :desc).map(&:name)).to eq(%w(swimming jogging hiking fishing chess boating))
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -78,14 +78,14 @@ describe DatastaxRails::Relation do
|
|
78
78
|
%w(john jason michael tony billy jim phil).each_with_index do |name, i|
|
79
79
|
AuditLog.create!(uuid: "c1401540-f092-11e2-9001-6a5ab73a986#{i}", user: name, message: 'changed')
|
80
80
|
end
|
81
|
-
expect(AuditLog.unscoped.slow_order(user: :asc).map
|
81
|
+
expect(AuditLog.unscoped.slow_order(user: :asc).map(&:user)).to eq(%w(billy jason jim john michael phil tony))
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should manually order items coming from Cassandra in descending order' do
|
85
85
|
%w(john jason michael tony billy jim phil).each_with_index do |name, i|
|
86
86
|
AuditLog.create!(uuid: "c1401540-f092-11e2-9001-6a5ab73a986#{i}", user: name, message: 'changed')
|
87
87
|
end
|
88
|
-
expect(AuditLog.unscoped.slow_order(user: :desc).map
|
88
|
+
expect(AuditLog.unscoped.slow_order(user: :desc).map(&:user)).to eq(%w(tony phil michael john jim jason billy))
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -97,6 +97,18 @@ describe DatastaxRails::Relation do
|
|
97
97
|
expect(@relation.where(name: nil)).not_to be_empty
|
98
98
|
end
|
99
99
|
|
100
|
+
it 'should return documents with false' do
|
101
|
+
Default.create
|
102
|
+
Default.commit_solr
|
103
|
+
expect(Default.where(bool2: false)).not_to be_empty
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should not return documents with nil booleans' do
|
107
|
+
Default.create
|
108
|
+
Default.commit_solr
|
109
|
+
expect(Default.where(bool3: false)).to be_empty
|
110
|
+
end
|
111
|
+
|
100
112
|
it 'should return documents where a value is greater than the given value' do
|
101
113
|
Hobby.create(name: 'Swimming', complexity: 1.1)
|
102
114
|
@relation.commit_solr
|
@@ -121,14 +133,6 @@ describe DatastaxRails::Relation do
|
|
121
133
|
expect(@relation.where(complexity: { less_than: 2.0 })).not_to be_empty
|
122
134
|
end
|
123
135
|
|
124
|
-
it 'should allow arrays to be passed as OR queries' do
|
125
|
-
%w(fishing hiking boating jogging swimming chess).each do |word|
|
126
|
-
Hobby.create(name: word)
|
127
|
-
end
|
128
|
-
@relation.commit_solr
|
129
|
-
expect(@relation.where(name: %w(boating jogging chess skydiving)).size).to eq(3)
|
130
|
-
end
|
131
|
-
|
132
136
|
it 'should handle negative numbers without breaking' do
|
133
137
|
Hobby.create(name: 'jogging', complexity: -1.2)
|
134
138
|
@relation.commit_solr
|
@@ -155,6 +159,27 @@ describe DatastaxRails::Relation do
|
|
155
159
|
expect(@relation.where(complexity: 1..2)).not_to be_empty
|
156
160
|
expect(@relation.where(complexity: 2..3)).to be_empty
|
157
161
|
end
|
162
|
+
|
163
|
+
context 'with an array as a parameter' do
|
164
|
+
it 'becomes an OR query' do
|
165
|
+
%w(fishing hiking boating jogging swimming chess).each do |word|
|
166
|
+
Hobby.create(name: word)
|
167
|
+
end
|
168
|
+
@relation.commit_solr
|
169
|
+
expect(@relation.where(name: %w(boating jogging chess skydiving)).size).to eq(3)
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'against the primary key' do
|
173
|
+
it 'removes nil values' do
|
174
|
+
hobby = create(:hobby)
|
175
|
+
expect(@relation.where(id: [hobby.id, nil])).to eq([hobby])
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'returns an empty array on only nil values' do
|
179
|
+
expect(@relation.where(id: [nil, nil])).to be_empty
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
158
183
|
end
|
159
184
|
|
160
185
|
describe '#where_not' do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DatastaxRails::Base do
|
4
|
+
describe 'Serialization' do
|
5
|
+
context '#serializable_hash' do
|
6
|
+
subject { build_stubbed(:job) }
|
7
|
+
|
8
|
+
it 'converts Cql::UUIDs to strings' do
|
9
|
+
expect(subject.serializable_hash['id']).to be_a(String)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'converts nested Cql::UUIDs to strings' do
|
13
|
+
expect(subject.serializable_hash(include: :person)['person']['id']).to be_a(String)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|