pg_serializable 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/codecov.yml +1 -1
- data/lib/pg_serializable/version.rb +1 -1
- data/lib/pg_serializable/visitors/json.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4a5cdf3d08ff52acb34ee418e7288b830154d98c572f85cb83d07cd6c8e9d28
|
4
|
+
data.tar.gz: 075d6e05706f868bb0871201a40594c5bb85bbe80dd5fc8663308fb0a5d32f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad13d0f61c3d611ec91ebc0074adcf3a49be8ca3f9ce3c5d73e8557f0b2928a3fb74c3f1ae3c9fbe17e75ec30db92af539add503189efac7dcf40bbeb32a31a9
|
7
|
+
data.tar.gz: 3f7c59fd5f2a376a4155bf4028ec82daaacfa4d2ff9f3115f39b5a6980f883955a1716a4606aa686830a509d3c7d141922f2b9041b47f55de32b31cd7c411800
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# PgSerializable
|
2
2
|
[![codecov](https://codecov.io/gh/matthewjf/pg_serializable/branch/master/graph/badge.svg)](https://codecov.io/gh/matthewjf/pg_serializable)
|
3
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/f3450fdd21d38e2a2fe6/maintainability)](https://codeclimate.com/github/matthewjf/pg_serializable/maintainability)
|
4
4
|
|
5
5
|
## Description
|
6
6
|
|
@@ -598,6 +598,10 @@ Response:
|
|
598
598
|
]
|
599
599
|
```
|
600
600
|
|
601
|
+
### Single Table Inheritance
|
602
|
+
|
603
|
+
It works with single table inheritance. Traits must be defined on each class individually.
|
604
|
+
|
601
605
|
## Without Rails
|
602
606
|
|
603
607
|
Rails isn't a dependency of this gem. However, setting it up to work without Rails takes some work. The `specs/support` folder has the initialization code needed to run the gem with just `ActiveSupport` and `ActiveRecord`.
|
data/codecov.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
ignore:
|
2
|
-
- "spec"
|
2
|
+
- "spec/.*"
|
@@ -5,20 +5,22 @@ module PgSerializable
|
|
5
5
|
table_alias = next_alias!
|
6
6
|
|
7
7
|
klass = subject.class
|
8
|
+
base_class = klass.base_class
|
8
9
|
select_sql = json_build_object(visit(klass.trait_manager, trait: trait, table_alias: table_alias)).to_sql
|
9
|
-
from_sql =
|
10
|
+
from_sql = base_class.where(id: subject.id).limit(1).to_sql
|
10
11
|
|
11
|
-
|
12
|
+
base_class.select(select_sql).from("#{as(from_sql, table_alias)}")
|
12
13
|
end
|
13
14
|
|
14
15
|
def visit_relation(subject, table_alias: nil, trait: :default)
|
15
16
|
table_alias ||= next_alias!
|
16
17
|
|
17
18
|
klass = subject.klass
|
19
|
+
base_class = klass.base_class
|
18
20
|
select_sql = coalesce(json_agg(json_build_object(visit(klass.trait_manager, trait: trait, table_alias: table_alias)))).to_sql
|
19
21
|
from_sql = subject.to_sql
|
20
22
|
|
21
|
-
|
23
|
+
base_class.select(select_sql).from("#{as(from_sql, table_alias)}")
|
22
24
|
end
|
23
25
|
|
24
26
|
def visit_class(subject, trait: :default, **kwargs)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_serializable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- matthewjf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|