pg_serializable 2.1.1 → 3.1.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/Gemfile.lock +55 -59
- data/README.md +18 -1
- data/lib/pg_serializable/version.rb +1 -1
- data/lib/pg_serializable.rb +1 -2
- data/pg_serializable.gemspec +3 -5
- metadata +9 -38
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3189b97d351d9f7e935da2cbb6e18e294c4a8b340ff5287875e1b3ead6b9a357
|
|
4
|
+
data.tar.gz: 3cc26b7781eaf661c8a2179da986e8ecdaba8aeaa2dcab7955ed5e1ec7577448
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef0c93d924220937e74665c36b2f742531f8567cb5f255bcc920fcc51b3f753b086e6a745adbde29865f88faafb61c91b479d64c0c5c90a0977d8dc2beac0ac0
|
|
7
|
+
data.tar.gz: e3aca9920562d2c5c5dd6dc8d7fd2bacffec01b082096dea5cfea19b0f75cd194c18e52f66fe7651ad14cfe3a6dcf6572fe80b4c7c5e514fcb7a4df6a6f4ad16
|
data/Gemfile.lock
CHANGED
|
@@ -1,86 +1,82 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pg_serializable (
|
|
5
|
-
activerecord (>= 5.2, <
|
|
6
|
-
activesupport (>= 5.2, <
|
|
7
|
-
oj (~> 3.6)
|
|
4
|
+
pg_serializable (3.1.0)
|
|
5
|
+
activerecord (>= 5.2, < 8.0)
|
|
6
|
+
activesupport (>= 5.2, < 8.0)
|
|
8
7
|
pg (>= 1.1)
|
|
9
8
|
|
|
10
9
|
GEM
|
|
11
10
|
remote: https://rubygems.org/
|
|
12
11
|
specs:
|
|
13
|
-
activemodel (
|
|
14
|
-
activesupport (=
|
|
15
|
-
activerecord (
|
|
16
|
-
activemodel (=
|
|
17
|
-
activesupport (=
|
|
18
|
-
|
|
19
|
-
activesupport (5.2.3)
|
|
12
|
+
activemodel (7.0.0)
|
|
13
|
+
activesupport (= 7.0.0)
|
|
14
|
+
activerecord (7.0.0)
|
|
15
|
+
activemodel (= 7.0.0)
|
|
16
|
+
activesupport (= 7.0.0)
|
|
17
|
+
activesupport (7.0.0)
|
|
20
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
21
|
-
i18n (>=
|
|
22
|
-
minitest (
|
|
23
|
-
tzinfo (~>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
i18n (>= 1.6, < 2)
|
|
20
|
+
minitest (>= 5.1)
|
|
21
|
+
tzinfo (~> 2.0)
|
|
22
|
+
codecov (0.6.0)
|
|
23
|
+
simplecov (>= 0.15, < 0.22)
|
|
24
|
+
coderay (1.1.3)
|
|
25
|
+
concurrent-ruby (1.1.9)
|
|
26
|
+
database_cleaner (2.0.1)
|
|
27
|
+
database_cleaner-active_record (~> 2.0.0)
|
|
28
|
+
database_cleaner-active_record (2.0.1)
|
|
29
|
+
activerecord (>= 5.a)
|
|
30
|
+
database_cleaner-core (~> 2.0.0)
|
|
31
|
+
database_cleaner-core (2.0.1)
|
|
32
|
+
diff-lcs (1.4.4)
|
|
33
|
+
docile (1.4.0)
|
|
34
|
+
factory_bot (6.2.0)
|
|
35
|
+
activesupport (>= 5.0.0)
|
|
36
|
+
ffaker (2.20.0)
|
|
37
|
+
i18n (1.8.11)
|
|
38
38
|
concurrent-ruby (~> 1.0)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
rspec-
|
|
50
|
-
|
|
51
|
-
rspec-
|
|
52
|
-
rspec-
|
|
53
|
-
rspec-support (~> 3.8.0)
|
|
54
|
-
rspec-expectations (3.8.2)
|
|
39
|
+
method_source (1.0.0)
|
|
40
|
+
minitest (5.15.0)
|
|
41
|
+
pg (1.2.3)
|
|
42
|
+
pry (0.14.1)
|
|
43
|
+
coderay (~> 1.1)
|
|
44
|
+
method_source (~> 1.0)
|
|
45
|
+
rake (13.0.6)
|
|
46
|
+
rspec (3.10.0)
|
|
47
|
+
rspec-core (~> 3.10.0)
|
|
48
|
+
rspec-expectations (~> 3.10.0)
|
|
49
|
+
rspec-mocks (~> 3.10.0)
|
|
50
|
+
rspec-core (3.10.1)
|
|
51
|
+
rspec-support (~> 3.10.0)
|
|
52
|
+
rspec-expectations (3.10.1)
|
|
55
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
56
|
-
rspec-support (~> 3.
|
|
57
|
-
rspec-mocks (3.
|
|
54
|
+
rspec-support (~> 3.10.0)
|
|
55
|
+
rspec-mocks (3.10.2)
|
|
58
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
59
|
-
rspec-support (~> 3.
|
|
60
|
-
rspec-support (3.
|
|
61
|
-
simplecov (0.
|
|
57
|
+
rspec-support (~> 3.10.0)
|
|
58
|
+
rspec-support (3.10.3)
|
|
59
|
+
simplecov (0.21.2)
|
|
62
60
|
docile (~> 1.1)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
simplecov-html (0.
|
|
66
|
-
|
|
67
|
-
tzinfo (
|
|
68
|
-
|
|
69
|
-
url (0.3.2)
|
|
61
|
+
simplecov-html (~> 0.11)
|
|
62
|
+
simplecov_json_formatter (~> 0.1)
|
|
63
|
+
simplecov-html (0.12.3)
|
|
64
|
+
simplecov_json_formatter (0.1.3)
|
|
65
|
+
tzinfo (2.0.4)
|
|
66
|
+
concurrent-ruby (~> 1.0)
|
|
70
67
|
|
|
71
68
|
PLATFORMS
|
|
72
69
|
ruby
|
|
73
70
|
|
|
74
71
|
DEPENDENCIES
|
|
75
|
-
bundler (~> 1.16)
|
|
76
72
|
codecov
|
|
77
73
|
database_cleaner
|
|
78
74
|
factory_bot
|
|
79
75
|
ffaker
|
|
80
76
|
pg_serializable!
|
|
81
77
|
pry
|
|
82
|
-
rake (~>
|
|
78
|
+
rake (~> 13.0)
|
|
83
79
|
rspec (~> 3.0)
|
|
84
80
|
|
|
85
81
|
BUNDLED WITH
|
|
86
|
-
|
|
82
|
+
2.2.33
|
data/README.md
CHANGED
|
@@ -7,6 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
Serialize json directly from postgres (9.4+).
|
|
9
9
|
|
|
10
|
+
## Upgrading from version 2.x.x to 3.x.x
|
|
11
|
+
|
|
12
|
+
Serialization returns a PORO instead of a json string. If you have code like:
|
|
13
|
+
```ruby
|
|
14
|
+
OJ.load(Product.where(id: ids).json)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
You can replace it with:
|
|
18
|
+
```ruby
|
|
19
|
+
Product.where(id: ids).json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
To automatically use OJ to serialize your POROs to json strings, add this code to your initialization:
|
|
23
|
+
```ruby
|
|
24
|
+
Oj.optimize_rails()
|
|
25
|
+
```
|
|
26
|
+
|
|
10
27
|
## Motivation
|
|
11
28
|
Models:
|
|
12
29
|
```ruby
|
|
@@ -533,7 +550,7 @@ class Variation < ApplicationRecord
|
|
|
533
550
|
serializable do
|
|
534
551
|
default do
|
|
535
552
|
attributes :id
|
|
536
|
-
belongs_to
|
|
553
|
+
belongs_to :color
|
|
537
554
|
end
|
|
538
555
|
|
|
539
556
|
trait :for_products do
|
data/lib/pg_serializable.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require 'oj'
|
|
2
1
|
require 'active_support/concern'
|
|
3
2
|
require 'active_support/core_ext/module/delegation'
|
|
4
3
|
require 'pg_serializable/errors'
|
|
@@ -57,7 +56,7 @@ module PgSerializable
|
|
|
57
56
|
|
|
58
57
|
def to_pg_json(scope)
|
|
59
58
|
res = scope.as_json.first
|
|
60
|
-
|
|
59
|
+
res['coalesce'] || res['json_build_object']
|
|
61
60
|
end
|
|
62
61
|
|
|
63
62
|
private
|
data/pg_serializable.gemspec
CHANGED
|
@@ -21,17 +21,15 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
22
|
spec.require_paths = ["lib"]
|
|
23
23
|
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.16"
|
|
25
24
|
spec.add_development_dependency "codecov"
|
|
26
25
|
spec.add_development_dependency "database_cleaner"
|
|
27
26
|
spec.add_development_dependency "factory_bot"
|
|
28
27
|
spec.add_development_dependency "ffaker"
|
|
29
28
|
spec.add_development_dependency "pry"
|
|
30
|
-
spec.add_development_dependency "rake", "~>
|
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
31
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
32
31
|
|
|
33
|
-
spec.add_runtime_dependency "activesupport", ">= 5.2", "<
|
|
34
|
-
spec.add_runtime_dependency "activerecord", ">= 5.2", "<
|
|
32
|
+
spec.add_runtime_dependency "activesupport", ">= 5.2", "< 8.0"
|
|
33
|
+
spec.add_runtime_dependency "activerecord", ">= 5.2", "< 8.0"
|
|
35
34
|
spec.add_runtime_dependency "pg", ">= 1.1"
|
|
36
|
-
spec.add_runtime_dependency "oj", "~> 3.6"
|
|
37
35
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pg_serializable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- matthewjf
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1.16'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.16'
|
|
27
13
|
- !ruby/object:Gem::Dependency
|
|
28
14
|
name: codecov
|
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,14 +86,14 @@ dependencies:
|
|
|
100
86
|
requirements:
|
|
101
87
|
- - "~>"
|
|
102
88
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
89
|
+
version: '13.0'
|
|
104
90
|
type: :development
|
|
105
91
|
prerelease: false
|
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
93
|
requirements:
|
|
108
94
|
- - "~>"
|
|
109
95
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
96
|
+
version: '13.0'
|
|
111
97
|
- !ruby/object:Gem::Dependency
|
|
112
98
|
name: rspec
|
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -131,7 +117,7 @@ dependencies:
|
|
|
131
117
|
version: '5.2'
|
|
132
118
|
- - "<"
|
|
133
119
|
- !ruby/object:Gem::Version
|
|
134
|
-
version: '
|
|
120
|
+
version: '8.0'
|
|
135
121
|
type: :runtime
|
|
136
122
|
prerelease: false
|
|
137
123
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -141,7 +127,7 @@ dependencies:
|
|
|
141
127
|
version: '5.2'
|
|
142
128
|
- - "<"
|
|
143
129
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '
|
|
130
|
+
version: '8.0'
|
|
145
131
|
- !ruby/object:Gem::Dependency
|
|
146
132
|
name: activerecord
|
|
147
133
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -151,7 +137,7 @@ dependencies:
|
|
|
151
137
|
version: '5.2'
|
|
152
138
|
- - "<"
|
|
153
139
|
- !ruby/object:Gem::Version
|
|
154
|
-
version: '
|
|
140
|
+
version: '8.0'
|
|
155
141
|
type: :runtime
|
|
156
142
|
prerelease: false
|
|
157
143
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -161,7 +147,7 @@ dependencies:
|
|
|
161
147
|
version: '5.2'
|
|
162
148
|
- - "<"
|
|
163
149
|
- !ruby/object:Gem::Version
|
|
164
|
-
version: '
|
|
150
|
+
version: '8.0'
|
|
165
151
|
- !ruby/object:Gem::Dependency
|
|
166
152
|
name: pg
|
|
167
153
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -176,20 +162,6 @@ dependencies:
|
|
|
176
162
|
- - ">="
|
|
177
163
|
- !ruby/object:Gem::Version
|
|
178
164
|
version: '1.1'
|
|
179
|
-
- !ruby/object:Gem::Dependency
|
|
180
|
-
name: oj
|
|
181
|
-
requirement: !ruby/object:Gem::Requirement
|
|
182
|
-
requirements:
|
|
183
|
-
- - "~>"
|
|
184
|
-
- !ruby/object:Gem::Version
|
|
185
|
-
version: '3.6'
|
|
186
|
-
type: :runtime
|
|
187
|
-
prerelease: false
|
|
188
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
189
|
-
requirements:
|
|
190
|
-
- - "~>"
|
|
191
|
-
- !ruby/object:Gem::Version
|
|
192
|
-
version: '3.6'
|
|
193
165
|
description: serializes rails models from postgres (9.5+)
|
|
194
166
|
email:
|
|
195
167
|
- matthewjf@gmail.com
|
|
@@ -248,8 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
248
220
|
- !ruby/object:Gem::Version
|
|
249
221
|
version: '0'
|
|
250
222
|
requirements: []
|
|
251
|
-
|
|
252
|
-
rubygems_version: 2.7.6
|
|
223
|
+
rubygems_version: 3.0.3.1
|
|
253
224
|
signing_key:
|
|
254
225
|
specification_version: 4
|
|
255
226
|
summary: serializes rails models from postgres (9.5+)
|