valkyrie-sequel 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/valkyrie/sequel/persister.rb +5 -4
- data/lib/valkyrie/sequel/resource_factory/orm_converter.rb +1 -0
- data/lib/valkyrie/sequel/resource_factory/resource_converter.rb +1 -1
- data/lib/valkyrie/sequel/version.rb +1 -1
- data/valkyrie-sequel.gemspec +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6e9fe995f047640837186d5468d2c13c1a4bde5
|
4
|
+
data.tar.gz: 2802d8cdee2d9bc7a029be53053a8d2df0e56358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb9d0289ef5b574b75447c06531416f306db195ad9a3e213cba51ab4671bd3cf62504a107f5647f6a6f2262b45805d832ad88bfbbf5252d3b953d2a2963dd743
|
7
|
+
data.tar.gz: 9d38118312e0e27e71c8035b40eabc23c15719bbe33b87d4deb2e99fc1347f95384e457ee1480ebbab71d6072eff3750281dc96b8a8fc933ca6639365da27c13
|
data/.rubocop.yml
CHANGED
@@ -61,7 +61,7 @@ module Valkyrie::Sequel
|
|
61
61
|
resources.returning.insert_conflict(
|
62
62
|
target: :id,
|
63
63
|
update: update_branches,
|
64
|
-
update_where: { Sequel[:orm_resources][:lock_version] => Sequel[:excluded][:lock_version] }
|
64
|
+
update_where: { Sequel.function(:coalesce, Sequel[:orm_resources][:lock_version], 0) => Sequel[:excluded][:lock_version] }
|
65
65
|
)
|
66
66
|
end
|
67
67
|
|
@@ -69,7 +69,7 @@ module Valkyrie::Sequel
|
|
69
69
|
{
|
70
70
|
metadata: Sequel[:excluded][:metadata],
|
71
71
|
internal_resource: Sequel[:excluded][:internal_resource],
|
72
|
-
lock_version: Sequel[:excluded][:lock_version] + 1,
|
72
|
+
lock_version: Sequel.function(:coalesce, Sequel[:excluded][:lock_version], 0) + 1,
|
73
73
|
created_at: Sequel[:excluded][:created_at],
|
74
74
|
updated_at: Time.now.utc
|
75
75
|
}
|
@@ -109,6 +109,7 @@ module Valkyrie::Sequel
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
112
|
+
|
112
113
|
def delete(resource:)
|
113
114
|
resources.where(id: resource.id.to_s).delete
|
114
115
|
resource
|
@@ -135,8 +136,8 @@ module Valkyrie::Sequel
|
|
135
136
|
def update(resource:, attributes:)
|
136
137
|
relation = resources.where(id: attributes[:id])
|
137
138
|
if resource.optimistic_locking_enabled?
|
138
|
-
relation = relation.where(
|
139
|
-
attributes[:lock_version] = (Sequel
|
139
|
+
relation = relation.where(Sequel.function(:coalesce, :lock_version, 0) => attributes[:lock_version] || 0)
|
140
|
+
attributes[:lock_version] = (Sequel.function(:coalesce, :lock_version, 0) + 1)
|
140
141
|
end
|
141
142
|
attributes.delete(:lock_version) if attributes[:lock_version].nil?
|
142
143
|
output = relation.returning.update(attributes)
|
@@ -27,6 +27,7 @@ module Valkyrie::Sequel
|
|
27
27
|
# Construct the optimistic lock token using the adapter and lock version for the Resource
|
28
28
|
# @return [Valkyrie::Persistence::OptimisticLockToken]
|
29
29
|
def lock_token
|
30
|
+
return nil unless object[:lock_version].present?
|
30
31
|
@lock_token ||=
|
31
32
|
Valkyrie::Persistence::OptimisticLockToken.new(
|
32
33
|
adapter_id: resource_factory.adapter_id,
|
@@ -25,7 +25,7 @@ module Valkyrie::Sequel
|
|
25
25
|
# @param [ORM::Resource] orm_object
|
26
26
|
def process_lock_token(orm_object)
|
27
27
|
return unless resource.respond_to?(Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK)
|
28
|
-
postgres_token = resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK].find do |token|
|
28
|
+
postgres_token = (resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK] || []).find do |token|
|
29
29
|
token.adapter_id == resource_factory.adapter_id
|
30
30
|
end
|
31
31
|
return unless postgres_token
|
data/valkyrie-sequel.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_dependency "sequel"
|
25
25
|
spec.add_dependency "sequel_pg"
|
26
|
-
spec.add_dependency "valkyrie",
|
26
|
+
spec.add_dependency "valkyrie", '>= 1.5.0', '< 3.0.0'
|
27
27
|
spec.add_dependency "oj"
|
28
28
|
spec.add_development_dependency "bundler", "~> 1.16"
|
29
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valkyrie-sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trey Pendragon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -42,16 +42,22 @@ dependencies:
|
|
42
42
|
name: valkyrie
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.5.0
|
48
|
+
- - "<"
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
50
|
+
version: 3.0.0
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.5.0
|
58
|
+
- - "<"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: 3.0.0
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: oj
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|