datastax_rails 1.2.3 → 2.0.3
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/MIT-LICENSE +1 -1
- data/README.rdoc +20 -8
- data/config/schema.xml.erb +22 -19
- data/config/solrconfig.xml.erb +1 -1
- data/lib/cql-rb_extensions.rb +27 -0
- data/lib/datastax_rails.rb +13 -17
- data/lib/datastax_rails/associations/association.rb +1 -4
- data/lib/datastax_rails/associations/collection_proxy.rb +0 -13
- data/lib/datastax_rails/attribute_assignment.rb +28 -91
- data/lib/datastax_rails/attribute_methods.rb +109 -44
- data/lib/datastax_rails/attribute_methods/before_type_cast.rb +71 -0
- data/lib/datastax_rails/attribute_methods/dirty.rb +52 -11
- data/lib/datastax_rails/attribute_methods/primary_key.rb +87 -0
- data/lib/datastax_rails/attribute_methods/read.rb +120 -0
- data/lib/datastax_rails/attribute_methods/typecasting.rb +52 -21
- data/lib/datastax_rails/attribute_methods/write.rb +59 -0
- data/lib/datastax_rails/base.rb +227 -236
- data/lib/datastax_rails/cassandra_only_model.rb +25 -19
- data/lib/datastax_rails/column.rb +384 -0
- data/lib/datastax_rails/connection.rb +12 -13
- data/lib/datastax_rails/cql/alter_column_family.rb +0 -1
- data/lib/datastax_rails/cql/base.rb +15 -3
- data/lib/datastax_rails/cql/column_family.rb +2 -2
- data/lib/datastax_rails/cql/create_column_family.rb +7 -18
- data/lib/datastax_rails/cql/delete.rb +4 -9
- data/lib/datastax_rails/cql/insert.rb +2 -8
- data/lib/datastax_rails/cql/select.rb +4 -4
- data/lib/datastax_rails/cql/update.rb +8 -17
- data/lib/datastax_rails/dynamic_model.rb +98 -0
- data/lib/datastax_rails/payload_model.rb +19 -31
- data/lib/datastax_rails/persistence.rb +39 -54
- data/lib/datastax_rails/railtie.rb +1 -0
- data/lib/datastax_rails/reflection.rb +1 -1
- data/lib/datastax_rails/relation.rb +20 -20
- data/lib/datastax_rails/relation/batches.rb +18 -16
- data/lib/datastax_rails/relation/facet_methods.rb +1 -1
- data/lib/datastax_rails/relation/finder_methods.rb +6 -10
- data/lib/datastax_rails/relation/search_methods.rb +62 -48
- data/lib/datastax_rails/rsolr_client_wrapper.rb +1 -1
- data/lib/datastax_rails/schema/cassandra.rb +34 -62
- data/lib/datastax_rails/schema/migrator.rb +9 -24
- data/lib/datastax_rails/schema/solr.rb +13 -30
- data/lib/datastax_rails/schema_cache.rb +67 -0
- data/lib/datastax_rails/timestamps.rb +84 -11
- data/lib/datastax_rails/types/dirty_collection.rb +88 -0
- data/lib/datastax_rails/types/dynamic_list.rb +14 -0
- data/lib/datastax_rails/types/dynamic_map.rb +32 -0
- data/lib/datastax_rails/types/dynamic_set.rb +10 -0
- data/lib/datastax_rails/util/solr_repair.rb +4 -5
- data/lib/datastax_rails/validations.rb +6 -12
- data/lib/datastax_rails/validations/uniqueness.rb +0 -4
- data/lib/datastax_rails/version.rb +1 -1
- data/lib/datastax_rails/wide_storage_model.rb +13 -29
- data/lib/schema_migration.rb +4 -0
- data/spec/datastax_rails/associations_spec.rb +0 -1
- data/spec/datastax_rails/attribute_methods_spec.rb +9 -6
- data/spec/datastax_rails/base_spec.rb +26 -0
- data/spec/datastax_rails/column_spec.rb +238 -0
- data/spec/datastax_rails/cql/select_spec.rb +1 -1
- data/spec/datastax_rails/cql/update_spec.rb +2 -2
- data/spec/datastax_rails/persistence_spec.rb +29 -15
- data/spec/datastax_rails/relation/batches_spec.rb +5 -5
- data/spec/datastax_rails/relation/finder_methods_spec.rb +0 -20
- data/spec/datastax_rails/relation/search_methods_spec.rb +8 -0
- data/spec/datastax_rails/relation_spec.rb +7 -0
- data/spec/datastax_rails/schema/migrator_spec.rb +5 -10
- data/spec/datastax_rails/schema/solr_spec.rb +1 -1
- data/spec/datastax_rails/types/dynamic_list_spec.rb +20 -0
- data/spec/datastax_rails/types/dynamic_map_spec.rb +22 -0
- data/spec/datastax_rails/types/dynamic_set_spec.rb +16 -0
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/datastax.yml +6 -3
- data/spec/dummy/config/environments/development.rb +4 -5
- data/spec/dummy/config/environments/test.rb +0 -5
- data/spec/dummy/log/development.log +18 -0
- data/spec/dummy/log/test.log +36 -0
- data/spec/feature/dynamic_fields_spec.rb +9 -0
- data/spec/feature/overloaded_tables_spec.rb +24 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/default_consistency_shared_examples.rb +2 -2
- data/spec/support/models.rb +28 -14
- metadata +212 -188
- data/lib/datastax_rails/identity.rb +0 -64
- data/lib/datastax_rails/identity/abstract_key_factory.rb +0 -29
- data/lib/datastax_rails/identity/custom_key_factory.rb +0 -37
- data/lib/datastax_rails/identity/hashed_natural_key_factory.rb +0 -10
- data/lib/datastax_rails/identity/natural_key_factory.rb +0 -39
- data/lib/datastax_rails/identity/uuid_key_factory.rb +0 -27
- data/lib/datastax_rails/type.rb +0 -16
- data/lib/datastax_rails/types.rb +0 -9
- data/lib/datastax_rails/types/array_type.rb +0 -86
- data/lib/datastax_rails/types/base_type.rb +0 -42
- data/lib/datastax_rails/types/binary_type.rb +0 -19
- data/lib/datastax_rails/types/boolean_type.rb +0 -22
- data/lib/datastax_rails/types/date_type.rb +0 -23
- data/lib/datastax_rails/types/float_type.rb +0 -18
- data/lib/datastax_rails/types/integer_type.rb +0 -18
- data/lib/datastax_rails/types/string_type.rb +0 -16
- data/lib/datastax_rails/types/text_type.rb +0 -15
- data/lib/datastax_rails/types/time_type.rb +0 -23
- data/spec/datastax_rails/types/float_type_spec.rb +0 -31
- data/spec/datastax_rails/types/integer_type_spec.rb +0 -31
- data/spec/datastax_rails/types/time_type_spec.rb +0 -28
@@ -10,12 +10,12 @@ describe DatastaxRails::Relation do
|
|
10
10
|
Hobby.commit_solr
|
11
11
|
end
|
12
12
|
|
13
|
-
['cassandra', 'solr'].each do |
|
13
|
+
['cassandra', 'solr'].each do |access_method|
|
14
14
|
describe "#find_each" do
|
15
|
-
it "returns each record one at a time with #{
|
15
|
+
it "returns each record one at a time with #{access_method}" do
|
16
16
|
sleep(1)
|
17
17
|
missed_hobbies = ('a'..'l').to_a
|
18
|
-
@relation.send('with_'+
|
18
|
+
@relation.send('with_'+access_method).find_each(:batch_size => 5) do |hobby|
|
19
19
|
missed_hobbies.delete_if {|h| h == hobby.name}
|
20
20
|
end
|
21
21
|
missed_hobbies.should be_empty
|
@@ -23,9 +23,9 @@ describe DatastaxRails::Relation do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#find_in_batches" do
|
26
|
-
it "returns records in batches of the given size with #{
|
26
|
+
it "returns records in batches of the given size with #{access_method}" do
|
27
27
|
count = 12
|
28
|
-
@relation.send('with_'+
|
28
|
+
@relation.send('with_'+access_method).find_in_batches(:batch_size => 5) do |batch|
|
29
29
|
batch.size.should <= 5
|
30
30
|
count -= batch.size
|
31
31
|
end
|
@@ -53,26 +53,6 @@ describe DatastaxRails::Relation do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe "#find_by_" do
|
57
|
-
it "finds a record by an attribute" do
|
58
|
-
Boat.create(:name => 'Spooner')
|
59
|
-
Boat.commit_solr
|
60
|
-
Boat.find_all_by_name('Spooner').should_not be_nil
|
61
|
-
end
|
62
|
-
|
63
|
-
it "finds a record by an attribute with a space in it" do
|
64
|
-
Boat.create(:name => 'Water Lily')
|
65
|
-
Boat.commit_solr
|
66
|
-
Boat.find_by_name('Water Lily').should_not be_nil
|
67
|
-
end
|
68
|
-
|
69
|
-
it "finds a record by an attribute with a colon in it" do
|
70
|
-
Boat.create(:name => 'Dumb: Name')
|
71
|
-
Boat.commit_solr
|
72
|
-
Boat.find_by_name('Dumb: Name').should_not be_nil
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
56
|
describe "#find_by" do
|
77
57
|
it "finds a record by an attribute" do
|
78
58
|
Boat.create(:name => 'Spooner')
|
@@ -65,6 +65,14 @@ describe DatastaxRails::Relation do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
describe "#select" do
|
69
|
+
it "returns maps from solr automatically" do
|
70
|
+
Hobby.create!(:name => "legos", :components => {'squares' => 4, 'rectangles' => 6})
|
71
|
+
@relation.commit_solr
|
72
|
+
res = @relation.select(:components).with_solr.first.components.should have_key('squares')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
68
76
|
describe "#slow_order" do
|
69
77
|
it "should manually order items coming from Cassandra" do
|
70
78
|
%w[john jason michael tony billy jim phil].each_with_index do |name,i|
|
@@ -166,4 +166,11 @@ describe DatastaxRails::Relation do
|
|
166
166
|
results = Person.group(:nickname).count.should eq(6)
|
167
167
|
end
|
168
168
|
end
|
169
|
+
|
170
|
+
describe "#downcase_query" do
|
171
|
+
it "downcases a solr query while leaving operators untouched" do
|
172
|
+
solr_query = "This Query needs to be DOWNCASED AND it also searches DATES [2010-09-09T10:42:12Z TO 2011-08-08T09:23:34Z] OR maybe it just breaks"
|
173
|
+
expect(@relation.downcase_query(solr_query)).to eq("this query needs to be downcased AND it also searches dates [2010-09-09T10:42:12Z TO 2011-08-08T09:23:34Z] OR maybe it just breaks")
|
174
|
+
end
|
175
|
+
end
|
169
176
|
end
|
@@ -12,7 +12,7 @@ describe DatastaxRails::Schema::Migrator do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "calls #create_payload_column_family" do
|
15
|
-
expect(subject).to receive(:
|
15
|
+
expect(subject).to receive(:create_cql3_column_family).with(CarPayload)
|
16
16
|
subject.migrate_one(CarPayload)
|
17
17
|
end
|
18
18
|
end
|
@@ -23,7 +23,7 @@ describe DatastaxRails::Schema::Migrator do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "does not call #create_payload_column_family" do
|
26
|
-
expect(subject).not_to receive(:
|
26
|
+
expect(subject).not_to receive(:create_cql2_column_family).with(CarPayload)
|
27
27
|
subject.migrate_one(CarPayload)
|
28
28
|
end
|
29
29
|
end
|
@@ -33,11 +33,11 @@ describe DatastaxRails::Schema::Migrator do
|
|
33
33
|
context 'when column family does not exist' do
|
34
34
|
before(:each) do
|
35
35
|
subject.stub(:column_family_exists?).and_return(false)
|
36
|
-
subject.stub(:
|
36
|
+
subject.stub(:create_cql3_column_family)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "calls #create_wide_storage_column_family" do
|
40
|
-
expect(subject).to receive(:
|
40
|
+
expect(subject).to receive(:create_cql3_column_family).with(AuditLog)
|
41
41
|
subject.migrate_one(AuditLog)
|
42
42
|
end
|
43
43
|
|
@@ -53,7 +53,7 @@ describe DatastaxRails::Schema::Migrator do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "does not call #create_wide_storage_column_family" do
|
56
|
-
expect(subject).not_to receive(:
|
56
|
+
expect(subject).not_to receive(:create_cql3_column_family).with(AuditLog)
|
57
57
|
subject.migrate_one(AuditLog)
|
58
58
|
end
|
59
59
|
|
@@ -65,11 +65,6 @@ describe DatastaxRails::Schema::Migrator do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe 'normal models' do
|
68
|
-
it "calls #check_key_name" do
|
69
|
-
expect(subject).to receive(:check_key_name).with(Person).and_return(0)
|
70
|
-
subject.migrate_one(Person)
|
71
|
-
end
|
72
|
-
|
73
68
|
it "calls #check_missing_schema" do
|
74
69
|
expect(subject).to receive(:check_missing_schema).with(Person).and_return(0)
|
75
70
|
subject.migrate_one(Person)
|
@@ -23,7 +23,7 @@ describe DatastaxRails::Schema::Solr do
|
|
23
23
|
|
24
24
|
describe "#generate_solr_schema" do
|
25
25
|
it "uses a custom config if one is present" do
|
26
|
-
model = mock_model("Article", :column_family => 'articles', :name => 'Article', :attribute_definitions => {})
|
26
|
+
model = mock_model("Article", :column_family => 'articles', :name => 'Article', :attribute_definitions => {}, :primary_key => 'id', :<= => false)
|
27
27
|
expect(subject.generate_solr_schema(model)).to match(/This is my custom schema/)
|
28
28
|
end
|
29
29
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DatastaxRails::Types::DynamicList do
|
4
|
+
subject {described_class.new(double("record", :changed_attributes => {}, :attributes => {}), 'list', [])}
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
subject << "Test String 1"
|
8
|
+
subject << "Another Test String"
|
9
|
+
subject << "Test String 1"
|
10
|
+
end
|
11
|
+
|
12
|
+
it { should eq(["Test String 1", "Another Test String", "Test String 1"])}
|
13
|
+
its('record.changed_attributes') { should include('list' => []) }
|
14
|
+
its('record.attributes') { should include('list' => ["Test String 1", "Another Test String", "Test String 1"])}
|
15
|
+
|
16
|
+
it "preserves ordering" do
|
17
|
+
subject[1] = "Test String 2"
|
18
|
+
subject.should eq(["Test String 1", "Test String 2", "Test String 1"])
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DatastaxRails::Types::DynamicMap do
|
4
|
+
subject {described_class.new(double("record", :changed_attributes => {}, :attributes => {}), 'map', {})}
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
subject['mapkey'] = "Test String"
|
8
|
+
end
|
9
|
+
|
10
|
+
its(['mapkey']) { should eq("Test String")}
|
11
|
+
its('record.changed_attributes') { should include('map' => {}) }
|
12
|
+
its('record.attributes') { should include('map' => {'mapkey' => 'Test String'})}
|
13
|
+
|
14
|
+
it "automatically maps key names when setting values" do
|
15
|
+
subject['test'] = 'Test String'
|
16
|
+
expect(subject).to have_key('maptest')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "automatically maps key names when reading values" do
|
20
|
+
expect(subject['key']).to eq('Test String')
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DatastaxRails::Types::DynamicSet do
|
4
|
+
subject {described_class.new(double("record", :changed_attributes => {}, :attributes => {}), 'set', [])}
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
subject << "Test String 1"
|
8
|
+
subject << "Another Test String"
|
9
|
+
subject.add("Test String 1")
|
10
|
+
subject << nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it { should eq(Set.new(["Test String 1", "Another Test String", nil]))}
|
14
|
+
its('record.changed_attributes') { should include('set' => Set.new) }
|
15
|
+
its('record.attributes') { should include('set' => Set.new(["Test String 1", "Another Test String", nil]))}
|
16
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
productiont:
|
2
|
-
servers: ["127.0.0.1
|
2
|
+
servers: ["127.0.0.1"]
|
3
|
+
port: 9042
|
3
4
|
keyspace: "datastax_rails_development"
|
4
5
|
strategy_options: {"RS": "3"}
|
5
6
|
connection_options:
|
@@ -11,7 +12,8 @@ productiont:
|
|
11
12
|
path: /solr
|
12
13
|
|
13
14
|
development:
|
14
|
-
servers: ["127.0.0.1
|
15
|
+
servers: ["127.0.0.1"]
|
16
|
+
port: 9042
|
15
17
|
keyspace: "datastax_rails_development"
|
16
18
|
strategy_class: "org.apache.cassandra.locator.SimpleStrategy"
|
17
19
|
strategy_options: {"replication_factor": "1"}
|
@@ -22,7 +24,8 @@ development:
|
|
22
24
|
path: /solr
|
23
25
|
|
24
26
|
test:
|
25
|
-
servers: ["127.0.0.1
|
27
|
+
servers: ["127.0.0.1"]
|
28
|
+
port: 9042
|
26
29
|
keyspace: "datastax_rails_test"
|
27
30
|
strategy_class: "org.apache.cassandra.locator.SimpleStrategy"
|
28
31
|
strategy_options: {"replication_factor": "1"}
|
@@ -5,16 +5,15 @@ Dummy::Application.configure do
|
|
5
5
|
# every request. This slows down response time but is perfect for development
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
|
-
|
9
|
-
|
10
|
-
config.whiny_nils = true
|
8
|
+
|
9
|
+
config.eager_load = false
|
11
10
|
|
12
11
|
# Show full error reports and disable caching
|
13
12
|
config.consider_all_requests_local = true
|
14
|
-
config.action_controller.perform_caching = false
|
13
|
+
#config.action_controller.perform_caching = false
|
15
14
|
|
16
15
|
# Don't care if the mailer can't send
|
17
|
-
config.action_mailer.raise_delivery_errors = false
|
16
|
+
#config.action_mailer.raise_delivery_errors = false
|
18
17
|
|
19
18
|
# Print deprecation notices to the Rails logger
|
20
19
|
config.active_support.deprecation = :log
|
@@ -13,12 +13,8 @@ Dummy::Application.configure do
|
|
13
13
|
config.serve_static_assets = true
|
14
14
|
config.static_cache_control = "public, max-age=3600"
|
15
15
|
|
16
|
-
# Log error messages when you accidentally call methods on nil
|
17
|
-
config.whiny_nils = true
|
18
|
-
|
19
16
|
# Show full error reports and disable caching
|
20
17
|
config.consider_all_requests_local = true
|
21
|
-
config.action_controller.perform_caching = false
|
22
18
|
|
23
19
|
# Raise exceptions instead of rendering exception templates
|
24
20
|
config.action_dispatch.show_exceptions = false
|
@@ -29,7 +25,6 @@ Dummy::Application.configure do
|
|
29
25
|
# Tell Action Mailer not to deliver emails to the real world.
|
30
26
|
# The :test delivery method accumulates sent emails in the
|
31
27
|
# ActionMailer::Base.deliveries array.
|
32
|
-
config.action_mailer.delivery_method = :test
|
33
28
|
|
34
29
|
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
35
30
|
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
@@ -24175,3 +24175,21 @@ SELECT updated_at,birthdate,nickname,created_at,name FROM people USING CONSISTEN
|
|
24175
24175
|
cars insert (11.8ms) ec46e0da-c18e-11e2-8c1e-12c5f0df414b {"updated_at"=>"2013-05-20T21:57:18Z", "last_serviced_at"=>nil}
|
24176
24176
|
Connecting to database specified by database.yml
|
24177
24177
|
Connecting to database specified by database.yml
|
24178
|
+
Connecting to database specified by database.yml
|
24179
|
+
Connecting to database specified by database.yml
|
24180
|
+
Connecting to database specified by database.yml
|
24181
|
+
Connecting to database specified by database.yml
|
24182
|
+
Connecting to database specified by database.yml
|
24183
|
+
Connecting to database specified by database.yml
|
24184
|
+
Connecting to database specified by database.yml
|
24185
|
+
Connecting to database specified by database.yml
|
24186
|
+
Connecting to database specified by database.yml
|
24187
|
+
Connecting to database specified by database.yml
|
24188
|
+
Connecting to node at localhost:9042
|
24189
|
+
Connected to node df32aa34-e727-4f93-903d-1f0c2c9c9fe5 at localhost:9042 in data center DC1
|
24190
|
+
Looking for additional nodes
|
24191
|
+
No additional nodes found
|
24192
|
+
Cluster connection complete
|
24193
|
+
Connection to node df32aa34-e727-4f93-903d-1f0c2c9c9fe5 at localhost:9042 in data center DC1 unexpectedly closed
|
24194
|
+
DEPRECATION WARNING: Proc#bind is deprecated and will be removed in future versions. (called from __pry__ at (pry):7)
|
24195
|
+
DEPRECATION WARNING: Proc#bind is deprecated and will be removed in future versions. (called from __pry__ at (pry):9)
|
data/spec/dummy/log/test.log
CHANGED
@@ -15565,3 +15565,39 @@ Connecting to database specified by database.yml
|
|
15565
15565
|
Connecting to database specified by database.yml
|
15566
15566
|
Connecting to database specified by database.yml
|
15567
15567
|
Connecting to database specified by database.yml
|
15568
|
+
Connecting to database specified by database.yml
|
15569
|
+
Connecting to database specified by database.yml
|
15570
|
+
Connecting to database specified by database.yml
|
15571
|
+
Connecting to database specified by database.yml
|
15572
|
+
Connecting to database specified by database.yml
|
15573
|
+
Connecting to database specified by database.yml
|
15574
|
+
Connecting to database specified by database.yml
|
15575
|
+
Connecting to database specified by database.yml
|
15576
|
+
Connecting to database specified by database.yml
|
15577
|
+
Connecting to database specified by database.yml
|
15578
|
+
Connecting to database specified by database.yml
|
15579
|
+
Connecting to database specified by database.yml
|
15580
|
+
Connecting to database specified by database.yml
|
15581
|
+
Connecting to database specified by database.yml
|
15582
|
+
Connecting to database specified by database.yml
|
15583
|
+
Connecting to database specified by database.yml
|
15584
|
+
Connecting to database specified by database.yml
|
15585
|
+
Connecting to database specified by database.yml
|
15586
|
+
Connecting to database specified by database.yml
|
15587
|
+
Connecting to database specified by database.yml
|
15588
|
+
Connecting to database specified by database.yml
|
15589
|
+
Connecting to database specified by database.yml
|
15590
|
+
Connecting to database specified by database.yml
|
15591
|
+
Connecting to database specified by database.yml
|
15592
|
+
Connecting to database specified by database.yml
|
15593
|
+
Connecting to database specified by database.yml
|
15594
|
+
Connecting to database specified by database.yml
|
15595
|
+
Connecting to database specified by database.yml
|
15596
|
+
Connecting to database specified by database.yml
|
15597
|
+
Connecting to database specified by database.yml
|
15598
|
+
Connecting to database specified by database.yml
|
15599
|
+
Connecting to database specified by database.yml
|
15600
|
+
Connecting to database specified by database.yml
|
15601
|
+
Connecting to database specified by database.yml
|
15602
|
+
Connecting to database specified by database.yml
|
15603
|
+
Connecting to database specified by database.yml
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "Dynamic Fields" do
|
4
|
+
scenario "map entries dynamically populate solr fields" do
|
5
|
+
Person.create!(:name => 'Steve', :str_ => {'str_favorite_color' => 'blue'})
|
6
|
+
Person.commit_solr
|
7
|
+
expect(Person.where(:str_favorite_color => 'blue')).to have(1).entry
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "Table Overloads" do
|
4
|
+
scenario "models writing to the same column family do not collide" do
|
5
|
+
core_meta = CoreMetadata.new
|
6
|
+
core_meta.strings[:source] = "BBC"
|
7
|
+
core_meta.strings[:author] = "John"
|
8
|
+
core_meta.timestamps[:published_at] = Time.now
|
9
|
+
core_meta.save
|
10
|
+
|
11
|
+
team_meta = TeamMetadata.new
|
12
|
+
team_meta.id = core_meta.id
|
13
|
+
team_meta.strings[:source] = "TV"
|
14
|
+
team_meta.strings[:medium] = 'television'
|
15
|
+
team_meta.dates[:published_on] = Date.today
|
16
|
+
team_meta.save
|
17
|
+
|
18
|
+
CoreMetadata.commit_solr
|
19
|
+
|
20
|
+
|
21
|
+
expect(CoreMetadata.fulltext('BBC')).to have(1).entry
|
22
|
+
expect(CoreMetadata.fulltext('TV')).to have(0).entries
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -29,7 +29,7 @@ RSpec.configure do |config|
|
|
29
29
|
|
30
30
|
config.after(:each) do
|
31
31
|
DatastaxRails::Base.recorded_classes.keys.each do |klass|
|
32
|
-
DatastaxRails::Base.connection.
|
32
|
+
DatastaxRails::Base.connection.execute("TRUNCATE #{klass.column_family.to_s}")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -3,14 +3,14 @@ require 'spec_helper'
|
|
3
3
|
shared_examples_for 'default_consistency' do
|
4
4
|
it "should default to QUORUM" do
|
5
5
|
cql = DatastaxRails::Cql::Select.new(@model_class, ["*"])
|
6
|
-
DatastaxRails::Base.connection.should_receive(:
|
6
|
+
DatastaxRails::Base.connection.should_receive(:execute).with(anything, :consistency => :quorum)
|
7
7
|
cql.execute
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should default to level specified by model class" do
|
11
11
|
@model_class.stub(:default_consistency => 'LOCAL_QUORUM')
|
12
12
|
cql = DatastaxRails::Cql::Select.new(@model_class, ["*"])
|
13
|
-
DatastaxRails::Base.connection.should_receive(:
|
13
|
+
DatastaxRails::Base.connection.should_receive(:execute).with(anything, :consistency => :local_quorum)
|
14
14
|
cql.execute
|
15
15
|
end
|
16
16
|
end
|
data/spec/support/models.rb
CHANGED
@@ -5,10 +5,12 @@ class Person < DatastaxRails::Base
|
|
5
5
|
has_many :cars, :dependent => :destroy
|
6
6
|
has_and_belongs_to_many :hobbies
|
7
7
|
|
8
|
-
|
8
|
+
uuid :id
|
9
9
|
text :name, :sortable => true
|
10
10
|
date :birthdate
|
11
11
|
string :nickname
|
12
|
+
set :email_addresses
|
13
|
+
map :str_
|
12
14
|
timestamps
|
13
15
|
|
14
16
|
before_create :set_variable2
|
@@ -35,11 +37,12 @@ class Car < DatastaxRails::Base
|
|
35
37
|
|
36
38
|
belongs_to :person
|
37
39
|
|
38
|
-
|
40
|
+
uuid :id
|
39
41
|
string :name
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
uuid :person_id
|
43
|
+
uuid :car_payload_id
|
44
|
+
datetime :last_serviced_at
|
45
|
+
map :oil_changes, :holds => :timestamp
|
43
46
|
timestamps
|
44
47
|
end
|
45
48
|
|
@@ -48,14 +51,15 @@ class CarPayload < DatastaxRails::PayloadModel
|
|
48
51
|
end
|
49
52
|
|
50
53
|
class AuditLog < DatastaxRails::WideStorageModel
|
54
|
+
include DatastaxRails::CassandraOnlyModel
|
51
55
|
self.column_family = "audit_logs"
|
56
|
+
self.primary_key = :uuid
|
57
|
+
self.cluster_by = :created_at
|
58
|
+
self.create_options = 'CLUSTERING ORDER BY (created_at DESC)'
|
52
59
|
|
53
|
-
|
54
|
-
cluster_by :created_at
|
55
|
-
|
56
|
-
string :uuid
|
60
|
+
uuid :uuid
|
57
61
|
string :message
|
58
|
-
string :user, :
|
62
|
+
string :user, :cql_index => true
|
59
63
|
timestamps
|
60
64
|
end
|
61
65
|
|
@@ -64,10 +68,11 @@ class Job < DatastaxRails::Base
|
|
64
68
|
|
65
69
|
belongs_to :person
|
66
70
|
|
67
|
-
|
71
|
+
uuid :id
|
68
72
|
string :title
|
69
73
|
integer :position_number
|
70
|
-
|
74
|
+
uuid :person_id
|
75
|
+
list :former_positions, :holds => :integer
|
71
76
|
timestamps
|
72
77
|
|
73
78
|
validates :position_number, :uniqueness => true, :allow_blank => true
|
@@ -76,7 +81,7 @@ end
|
|
76
81
|
class Boat < DatastaxRails::Base
|
77
82
|
self.column_family = "boats"
|
78
83
|
|
79
|
-
|
84
|
+
uuid :id
|
80
85
|
string :name
|
81
86
|
integer :registration
|
82
87
|
timestamps
|
@@ -90,8 +95,17 @@ class Hobby < DatastaxRails::Base
|
|
90
95
|
|
91
96
|
has_and_belongs_to_many :people
|
92
97
|
|
93
|
-
|
98
|
+
uuid :id
|
94
99
|
string :name
|
95
100
|
float :complexity
|
101
|
+
map :components, :holds => :integer
|
96
102
|
timestamps
|
97
103
|
end
|
104
|
+
|
105
|
+
class CoreMetadata < DatastaxRails::DynamicModel
|
106
|
+
self.group_by = 'core'
|
107
|
+
end
|
108
|
+
|
109
|
+
class TeamMetadata < DatastaxRails::DynamicModel
|
110
|
+
self.group_by = 'team'
|
111
|
+
end
|