gotime-cassandra_object 4.11.4 → 4.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gotime-cassandra_object.gemspec +1 -1
- data/lib/cassandra_object/base.rb +0 -1
- data/lib/cassandra_object/persistence.rb +1 -1
- data/lib/cassandra_object/schema/tasks.rb +1 -1
- data/lib/cassandra_object/scope/query_methods.rb +4 -4
- data/lib/gotime-cassandra_object.rb +0 -1
- metadata +15 -17
- data/lib/cassandra_object/savepoints.rb +0 -79
- data/test/unit/savepoints_test.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f4ae8a2098007fdcbcd6847250f1f1a6ec7d796
|
4
|
+
data.tar.gz: 1f771e3e05b8fd02c75368d9bb4d267625ae65c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba97e2ce536c92b6350a9a967276a8e75807c38b63c6e088041e29ed77110f2f5607ff9f820a5c449bc2e2445c9721548739aa3f7115e2ba8b75b6761b101756
|
7
|
+
data.tar.gz: ecf1f7f1eec3c482cc31df0797c044bf28505285728169e47f49ab8aa8cf33dbc29ed63bad3bec0fd6b31654eb69904592c6937c37a6a51ecca9302b50743754
|
@@ -26,7 +26,7 @@ module CassandraObject
|
|
26
26
|
|
27
27
|
def write(id, attributes)
|
28
28
|
if (encoded = encode_attributes(attributes)).any?
|
29
|
-
insert_attributes = {'KEY' => id}.update
|
29
|
+
insert_attributes = {'KEY' => id}.update(encoded)
|
30
30
|
statement = "INSERT INTO #{column_family} (#{quote_columns(insert_attributes.keys) * ','}) VALUES (#{Array.new(insert_attributes.size, '?') * ','})#{write_option_string}"
|
31
31
|
execute_batchable_cql statement, *insert_attributes.values
|
32
32
|
end
|
@@ -34,10 +34,10 @@ module CassandraObject
|
|
34
34
|
|
35
35
|
def to_cql
|
36
36
|
[
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
"SELECT #{select_string} FROM #{klass.column_family}",
|
38
|
+
consistency_string,
|
39
|
+
where_string,
|
40
|
+
limit_string
|
41
41
|
].delete_if(&:blank?) * ' '
|
42
42
|
end
|
43
43
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotime-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.11.
|
4
|
+
version: 4.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Koziarski
|
@@ -9,62 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '3.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '3.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: cassandra-cql
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: thrift_client
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 0.9.0
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 0.9.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
description: Cassandra ActiveModel
|
@@ -74,8 +74,8 @@ extensions: []
|
|
74
74
|
extra_rdoc_files:
|
75
75
|
- README.rdoc
|
76
76
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .travis.yml
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
79
|
- CHANGELOG
|
80
80
|
- Gemfile
|
81
81
|
- LICENSE
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- lib/cassandra_object/model.rb
|
107
107
|
- lib/cassandra_object/persistence.rb
|
108
108
|
- lib/cassandra_object/railtie.rb
|
109
|
-
- lib/cassandra_object/savepoints.rb
|
110
109
|
- lib/cassandra_object/schema.rb
|
111
110
|
- lib/cassandra_object/schema/tasks.rb
|
112
111
|
- lib/cassandra_object/scope.rb
|
@@ -154,7 +153,6 @@ files:
|
|
154
153
|
- test/unit/inspect_test.rb
|
155
154
|
- test/unit/log_subscriber_test.rb
|
156
155
|
- test/unit/persistence_test.rb
|
157
|
-
- test/unit/savepoints_test.rb
|
158
156
|
- test/unit/schema/tasks_test.rb
|
159
157
|
- test/unit/schema_test.rb
|
160
158
|
- test/unit/scope/batches_test.rb
|
@@ -182,17 +180,17 @@ require_paths:
|
|
182
180
|
- lib
|
183
181
|
required_ruby_version: !ruby/object:Gem::Requirement
|
184
182
|
requirements:
|
185
|
-
- -
|
183
|
+
- - ">="
|
186
184
|
- !ruby/object:Gem::Version
|
187
185
|
version: 1.9.2
|
188
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
187
|
requirements:
|
190
|
-
- -
|
188
|
+
- - ">="
|
191
189
|
- !ruby/object:Gem::Version
|
192
190
|
version: 1.3.5
|
193
191
|
requirements: []
|
194
192
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.2.1
|
196
194
|
signing_key:
|
197
195
|
specification_version: 4
|
198
196
|
summary: Cassandra ActiveModel
|
@@ -1,79 +0,0 @@
|
|
1
|
-
module CassandraObject
|
2
|
-
module Savepoints
|
3
|
-
class Rollback
|
4
|
-
attr_accessor :action, :record, :rollback_attributes
|
5
|
-
def initialize(action, record)
|
6
|
-
@action = action
|
7
|
-
@record = record
|
8
|
-
if action == :update
|
9
|
-
@rollback_attributes = record.changed_attributes.deep_dup
|
10
|
-
elsif action == :create
|
11
|
-
@rollback_attributes = record.attributes.deep_dup
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def run!
|
16
|
-
case action
|
17
|
-
when :destroy
|
18
|
-
record.class.remove(record.id)
|
19
|
-
when :create, :update
|
20
|
-
record.class.write(record.id, rollback_attributes)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Savepoint
|
26
|
-
attr_accessor :rollbacks
|
27
|
-
def initialize
|
28
|
-
self.rollbacks = []
|
29
|
-
end
|
30
|
-
|
31
|
-
def add_rollback(action, record)
|
32
|
-
states << Rollback.new(action, record)
|
33
|
-
end
|
34
|
-
|
35
|
-
def rollback!
|
36
|
-
rollbacks.reverse_each(&:run!)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
extend ActiveSupport::Concern
|
41
|
-
|
42
|
-
included do
|
43
|
-
class_attribute :savepoints
|
44
|
-
self.savepoints = []
|
45
|
-
end
|
46
|
-
|
47
|
-
module ClassMethods
|
48
|
-
def savepoint
|
49
|
-
self.savepoints.push Savepoint.new
|
50
|
-
yield
|
51
|
-
savepoints.pop
|
52
|
-
rescue => e
|
53
|
-
savepoints.pop.rollback!
|
54
|
-
end
|
55
|
-
|
56
|
-
def add_savepoint_rollback(action, record)
|
57
|
-
unless savepoints.empty?
|
58
|
-
savepoints.last.add_rollback(action, record)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def destroy
|
64
|
-
self.class.add_savepoint_rollback(:create, self)
|
65
|
-
super
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
def create
|
70
|
-
self.class.add_savepoint_rollback(:destroy, self)
|
71
|
-
super
|
72
|
-
end
|
73
|
-
|
74
|
-
def update
|
75
|
-
self.class.add_savepoint_rollback(:update, self)
|
76
|
-
super
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CassandraObject::SavepointsTest < CassandraObject::TestCase
|
4
|
-
test 'rollback create' do
|
5
|
-
Issue.savepoint do
|
6
|
-
issue = Issue.create description: 'foo'
|
7
|
-
raise 'lol'
|
8
|
-
end
|
9
|
-
|
10
|
-
assert_nil Issue.first
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'rollback update' do
|
14
|
-
issue = Issue.create description: 'foo'
|
15
|
-
|
16
|
-
Issue.savepoint do
|
17
|
-
issue.update_attributes description: 'bar'
|
18
|
-
raise 'lol'
|
19
|
-
end
|
20
|
-
|
21
|
-
issue = Issue.find issue.id
|
22
|
-
assert_equal 'foo', issue.description
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'rollback destroy' do
|
26
|
-
issue = Issue.create description: 'foo'
|
27
|
-
|
28
|
-
Issue.savepoint do
|
29
|
-
issue.destroy
|
30
|
-
raise 'lol'
|
31
|
-
end
|
32
|
-
|
33
|
-
assert_nothing_raised { Issue.find issue.id }
|
34
|
-
end
|
35
|
-
end
|