active_record-json_associations 0.11.0 → 0.13.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 +2 -9
- data/Appraisals +7 -14
- data/README.md +1 -1
- data/gemfiles/rails_7.0.gemfile +1 -0
- data/gemfiles/{rails_5.1.gemfile → rails_7.1.gemfile} +1 -1
- data/gemfiles/{rails_5.2.gemfile → rails_7.2.gemfile} +1 -1
- data/lib/active_record/json_associations/version.rb +1 -1
- data/lib/active_record/json_associations.rb +19 -5
- metadata +5 -7
- data/gemfiles/rails_6.0.gemfile +0 -7
- data/gemfiles/rails_6.1.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: c6e92de811720d3a6f9ed242d374f6f4b6e604e09977476f619355918c22b6ea
|
|
4
|
+
data.tar.gz: 31e0f02c6b52dbc6994d3d4c2ae7016287a2d2488ad1371ddac6ba65bf9598d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1773bd6dd9c36865e772b81c6e0c7ac9ece43028cdc1c5e254047dcc5349bb0cc4a8073b30de3cd114bed20be88ab30495b6f5b2f9a241caa78f9fd8c1a67908
|
|
7
|
+
data.tar.gz: 4312ec59acc30da426d32c53dea432bcdd2064a21fea69faa826f6dd1347887668e6fc7280be9a107973ad9ac6f19745e43df382c573831b71623ed3f8889a32
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -5,15 +5,8 @@ jobs:
|
|
|
5
5
|
strategy:
|
|
6
6
|
fail-fast: false
|
|
7
7
|
matrix:
|
|
8
|
-
gemfile: [
|
|
9
|
-
ruby: [
|
|
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
|
|
8
|
+
gemfile: [ rails_7.0, rails_7.1, rails_7.2 ]
|
|
9
|
+
ruby: [ 3.1, 3.2, 3.3 ]
|
|
17
10
|
|
|
18
11
|
runs-on: ubuntu-latest
|
|
19
12
|
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
data/Appraisals
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
appraise "rails-
|
|
2
|
-
gem "rails", "~>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
appraise "rails-5.2" do
|
|
6
|
-
gem "rails", "~>5.2.0"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
appraise "rails-6.0" do
|
|
10
|
-
gem "rails", "~>6.0.0"
|
|
1
|
+
appraise "rails-7.0" do
|
|
2
|
+
gem "rails", "~>7.0.0"
|
|
3
|
+
gem "sqlite3", "~>1.0"
|
|
11
4
|
end
|
|
12
5
|
|
|
13
|
-
appraise "rails-
|
|
14
|
-
gem "rails", "~>
|
|
6
|
+
appraise "rails-7.1" do
|
|
7
|
+
gem "rails", "~>7.1.0"
|
|
15
8
|
end
|
|
16
9
|
|
|
17
|
-
appraise "rails-7.
|
|
18
|
-
gem "rails", "~>7.
|
|
10
|
+
appraise "rails-7.2" do
|
|
11
|
+
gem "rails", "~>7.2.0"
|
|
19
12
|
end
|
|
20
13
|
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ActiveRecord::JsonAssociations
|
|
2
2
|
|
|
3
|
-
[](https://github.com/botandrose/active_record-json_associations/actions/workflows/ci.yml)
|
|
4
4
|
[](https://codeclimate.com/github/botandrose/active_record-json_associations)
|
|
5
5
|
|
|
6
6
|
Instead of keeping the foreign keys on the children, or in a many-to-many join table, let's keep them in a JSON array on the parent.
|
data/gemfiles/rails_7.0.gemfile
CHANGED
|
@@ -4,10 +4,16 @@ require "json"
|
|
|
4
4
|
module ActiveRecord
|
|
5
5
|
module JsonAssociations
|
|
6
6
|
FIELD_INCLUDE_SCOPE_BUILDER_PROC = proc do |context, field, id|
|
|
7
|
-
context.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
using_json = context.columns_hash[field.to_s].type == :json
|
|
8
|
+
|
|
9
|
+
if using_json
|
|
10
|
+
context.where("JSON_CONTAINS(#{field}, ?, '$')", id.to_json)
|
|
11
|
+
else
|
|
12
|
+
context.where("#{field}='[#{id}]'").or(
|
|
13
|
+
context.where("#{field} LIKE '[#{id},%'")).or(
|
|
14
|
+
context.where("#{field} LIKE '%,#{id},%'")).or(
|
|
15
|
+
context.where("#{field} LIKE '%,#{id}]'"))
|
|
16
|
+
end
|
|
11
17
|
end
|
|
12
18
|
private_constant :FIELD_INCLUDE_SCOPE_BUILDER_PROC
|
|
13
19
|
|
|
@@ -20,7 +26,15 @@ module ActiveRecord
|
|
|
20
26
|
|
|
21
27
|
class_name ||= one.classify
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
using_json = columns_hash[one_ids.to_s].type == :json
|
|
30
|
+
|
|
31
|
+
if !using_json
|
|
32
|
+
if ActiveRecord.version >= Gem::Version.new("7.1")
|
|
33
|
+
serialize one_ids, coder: JSON
|
|
34
|
+
else
|
|
35
|
+
serialize one_ids, JSON
|
|
36
|
+
end
|
|
37
|
+
end
|
|
24
38
|
|
|
25
39
|
if touch
|
|
26
40
|
after_commit 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.13.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: 2025-01-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -140,11 +140,9 @@ files:
|
|
|
140
140
|
- Rakefile
|
|
141
141
|
- active_record-json_associations.gemspec
|
|
142
142
|
- bin/setup
|
|
143
|
-
- gemfiles/rails_5.1.gemfile
|
|
144
|
-
- gemfiles/rails_5.2.gemfile
|
|
145
|
-
- gemfiles/rails_6.0.gemfile
|
|
146
|
-
- gemfiles/rails_6.1.gemfile
|
|
147
143
|
- gemfiles/rails_7.0.gemfile
|
|
144
|
+
- gemfiles/rails_7.1.gemfile
|
|
145
|
+
- gemfiles/rails_7.2.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.5.11
|
|
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/gemfiles/rails_6.0.gemfile
DELETED