active_record-json_associations 0.10.0 → 0.12.0
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/.github/workflows/ci.yml +30 -0
- data/Appraisals +6 -15
- data/gemfiles/{rails_6.0.gemfile → rails_7.0.gemfile} +1 -1
- data/gemfiles/{rails_5.1.gemfile → rails_7.1.gemfile} +1 -1
- data/lib/active_record/json_associations/version.rb +1 -1
- data/lib/active_record/json_associations.rb +21 -14
- data/spec/json_associations_spec.rb +8 -0
- metadata +6 -8
- data/.travis.yml +0 -18
- data/gemfiles/rails_5.0.gemfile +0 -8
- data/gemfiles/rails_5.2.gemfile +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d6216fb9d4e62c9c8cb923d201468dcf3cf6843b287e747a068fd646e9c49a3f
|
|
4
|
+
data.tar.gz: 31f562eb9e8e9f2d029a59539977bb2e10a21555532b1dc3031a971487335f69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3913f45325fbd16a2983f9ec5e9d38d9f4121984d585baacb782a40ad01b54c99de287eeca8151b2aa1556153aee3157d8776c9f0515688e5122ffd7f0b61a5
|
|
7
|
+
data.tar.gz: 7a280e3431ed93c53719ced45e48dc85f39c797ffd2e39483a8bb060a3f18d63c3f1c99ff3c33a5b55e1f1c74fe0721b5786fa2b28853aefb035dbf91e3e40dc
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
test:
|
|
5
|
+
strategy:
|
|
6
|
+
fail-fast: false
|
|
7
|
+
matrix:
|
|
8
|
+
gemfile: [ rails_6.1, rails_7.0, rails_7.1 ]
|
|
9
|
+
ruby: [ 2.6, 2.7, '3.0', 3.1, 3.2 ]
|
|
10
|
+
exclude:
|
|
11
|
+
- gemfile: rails_5.1
|
|
12
|
+
ruby: 3.0
|
|
13
|
+
- gemfile: rails_5.2
|
|
14
|
+
ruby: 3.0
|
|
15
|
+
- gemfile: rails_7.0
|
|
16
|
+
ruby: 2.6
|
|
17
|
+
- gemfile: rails_7.1
|
|
18
|
+
ruby: 2.6
|
|
19
|
+
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
|
22
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v2
|
|
25
|
+
- uses: ruby/setup-ruby@v1
|
|
26
|
+
with:
|
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
|
28
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
29
|
+
- run: bundle exec rake
|
|
30
|
+
|
data/Appraisals
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
appraise "rails-
|
|
2
|
-
gem "rails", "~>
|
|
3
|
-
gem "sqlite3", "~>1.3.13" # 1.4 seems to break rails 5.0?
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
appraise "rails-5.1" do
|
|
7
|
-
gem "rails", "~>5.1.0"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
appraise "rails-5.2" do
|
|
11
|
-
gem "rails", "~>5.2.0"
|
|
1
|
+
appraise "rails-6.1" do
|
|
2
|
+
gem "rails", "~>6.1.0"
|
|
12
3
|
end
|
|
13
4
|
|
|
14
|
-
appraise "rails-
|
|
15
|
-
gem "rails", "~>
|
|
5
|
+
appraise "rails-7.0" do
|
|
6
|
+
gem "rails", "~>7.0.0"
|
|
16
7
|
end
|
|
17
8
|
|
|
18
|
-
appraise "rails-
|
|
19
|
-
gem "rails", "~>
|
|
9
|
+
appraise "rails-7.1" do
|
|
10
|
+
gem "rails", "~>7.1.0"
|
|
20
11
|
end
|
|
21
12
|
|
|
@@ -20,24 +20,31 @@ module ActiveRecord
|
|
|
20
20
|
|
|
21
21
|
class_name ||= one.classify
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
if ActiveRecord.version >= Gem::Version.new("7.1")
|
|
25
|
+
serialize one_ids, coder: JSON
|
|
26
|
+
else
|
|
27
|
+
serialize one_ids, JSON
|
|
28
|
+
end
|
|
24
29
|
|
|
25
30
|
if touch
|
|
26
31
|
after_commit do
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
scope.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
attributes.
|
|
32
|
+
unless no_touching?
|
|
33
|
+
method = respond_to?(:saved_changes) ? :saved_changes : :previous_changes
|
|
34
|
+
old_ids, new_ids = send(method)[one_ids.to_s]
|
|
35
|
+
ids = Array(send(one_ids)) | Array(old_ids) | Array(new_ids)
|
|
36
|
+
scope = class_name.constantize.where(self.class.primary_key => ids)
|
|
37
|
+
|
|
38
|
+
if scope.respond_to?(:touch) # AR 6.0+
|
|
39
|
+
scope.touch_all
|
|
40
|
+
elsif self.class.respond_to?(:touch_attributes_with_time) # AR 5.1+
|
|
41
|
+
scope.update_all self.class.touch_attributes_with_time
|
|
42
|
+
else # AR 5.0
|
|
43
|
+
attributes = timestamp_attributes_for_update_in_model.inject({}) do |attributes, key|
|
|
44
|
+
attributes.merge(key => current_time_from_proper_timezone)
|
|
45
|
+
end
|
|
46
|
+
scope.update_all attributes
|
|
39
47
|
end
|
|
40
|
-
scope.update_all attributes
|
|
41
48
|
end
|
|
42
49
|
end
|
|
43
50
|
end
|
|
@@ -185,6 +185,14 @@ describe ActiveRecord::JsonAssociations do
|
|
|
185
185
|
parent.update!(children: [peter, paul, mary])
|
|
186
186
|
expect([peter, paul, mary].each(&:reload).map(&:updated_at)).to eq [new_time, new_time, new_time]
|
|
187
187
|
end
|
|
188
|
+
|
|
189
|
+
it "skips touching if in a .no_touching block" do
|
|
190
|
+
children = [Child.create!, Child.create!]
|
|
191
|
+
parent = Parent.create!(children: children)
|
|
192
|
+
children.each { |child| child.update!(updated_at: old_time) }
|
|
193
|
+
ActiveRecord::Base.no_touching { parent.save! }
|
|
194
|
+
expect(children.each(&:reload).map(&:updated_at)).to eq [old_time, old_time]
|
|
195
|
+
end
|
|
188
196
|
end
|
|
189
197
|
|
|
190
198
|
describe "#child_ids" do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_record-json_associations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -130,9 +130,9 @@ executables:
|
|
|
130
130
|
extensions: []
|
|
131
131
|
extra_rdoc_files: []
|
|
132
132
|
files:
|
|
133
|
+
- ".github/workflows/ci.yml"
|
|
133
134
|
- ".gitignore"
|
|
134
135
|
- ".rspec"
|
|
135
|
-
- ".travis.yml"
|
|
136
136
|
- Appraisals
|
|
137
137
|
- Gemfile
|
|
138
138
|
- LICENSE.txt
|
|
@@ -140,11 +140,9 @@ files:
|
|
|
140
140
|
- Rakefile
|
|
141
141
|
- active_record-json_associations.gemspec
|
|
142
142
|
- bin/setup
|
|
143
|
-
- gemfiles/rails_5.0.gemfile
|
|
144
|
-
- gemfiles/rails_5.1.gemfile
|
|
145
|
-
- gemfiles/rails_5.2.gemfile
|
|
146
|
-
- gemfiles/rails_6.0.gemfile
|
|
147
143
|
- gemfiles/rails_6.1.gemfile
|
|
144
|
+
- gemfiles/rails_7.0.gemfile
|
|
145
|
+
- gemfiles/rails_7.1.gemfile
|
|
148
146
|
- lib/active_record/json_associations.rb
|
|
149
147
|
- lib/active_record/json_associations/version.rb
|
|
150
148
|
- spec/json_associations_spec.rb
|
|
@@ -168,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
168
166
|
- !ruby/object:Gem::Version
|
|
169
167
|
version: '0'
|
|
170
168
|
requirements: []
|
|
171
|
-
rubygems_version: 3.
|
|
169
|
+
rubygems_version: 3.2.32
|
|
172
170
|
signing_key:
|
|
173
171
|
specification_version: 4
|
|
174
172
|
summary: Instead of a many-to-many join table, serialize the ids into a JSON array.
|
data/.travis.yml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
rvm:
|
|
3
|
-
- 2.4
|
|
4
|
-
- 2.5
|
|
5
|
-
- 2.6
|
|
6
|
-
- 2.7
|
|
7
|
-
gemfile:
|
|
8
|
-
- gemfiles/rails_5.0.gemfile
|
|
9
|
-
- gemfiles/rails_5.1.gemfile
|
|
10
|
-
- gemfiles/rails_5.2.gemfile
|
|
11
|
-
- gemfiles/rails_6.0.gemfile
|
|
12
|
-
jobs:
|
|
13
|
-
exclude:
|
|
14
|
-
- rvm: 2.4
|
|
15
|
-
gemfile: gemfiles/rails_6.0.gemfile
|
|
16
|
-
before_install:
|
|
17
|
-
- gem install bundler -v"~>1.17"
|
|
18
|
-
|
data/gemfiles/rails_5.0.gemfile
DELETED